ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:database:mysql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:database:mysql [2020/01/15 03:38] – [mysqli driver] mnewnhamv5:database:mysql [2026/01/30 03:48] (current) – [Connecting With SSL] mnewnham
Line 2: Line 2:
 ~~NOTOC~~ ~~NOTOC~~
 ===== mysqli driver ===== ===== mysqli driver =====
 +
 <WRAP right box round 300px> <WRAP right box round 300px>
 +
 == Specification == == Specification ==
 ^Driver Name|mysqli| ^Driver Name|mysqli|
Line 11: Line 13:
 ^ADOdb V5|Yes| ^ADOdb V5|Yes|
 ^ADOdb V6|Yes| ^ADOdb V6|Yes|
 +
 == Alternatives == == Alternatives ==
 [[v5:database:pdo#pdo_mysql|PDO driver for MySQL]] [[v5:database:pdo#pdo_mysql|PDO driver for MySQL]]
 +
 +== See Also ==
 +[[v5:reference:connection:setconnectionparameter#mysql|setConnectionParameter()]]
 </WRAP> </WRAP>
  
Line 23: Line 29:
  
 It replaces [[v5:database:mysql_legacy|]] (**mysql**, **mysqlt** and **mysqlpo**). It replaces [[v5:database:mysql_legacy|]] (**mysql**, **mysqlt** and **mysqlpo**).
 +
 +<WRAP important>
 +Starting with ADOdb 5.22, the mysqli driver requires the [[https://www.php.net/manual/en/book.mysqlnd.php|MySQL Native Driver (Mysqlnd)]]
 +</WRAP>
 +
  
 ------------------------------------------- -------------------------------------------
Line 43: Line 54:
 </code> </code>
 ==== Connecting With SSL ==== ==== Connecting With SSL ====
-From ADOdb version 5.21, you can make an SSL connection to MySQL in the following way:+From ADOdb version 5.23.10, you make an SSL connection to MySQL in the following way:
  
 <code php> <code php>
Line 49: Line 60:
 * Enable ADOdb * Enable ADOdb
 */ */
-$db = newAdoConnection('mysqli')+$db = newAdoConnection('mysqli');
 /* /*
 * Set the SSL parameters * Set the SSL parameters
 */ */
-$db->ssl_key    = "key.pem"; +$db->setConnectionParameter('ssl',
-$db->ssl_cert   = "cert.pem" +    'key' ="key.pem", 
-$db->ssl_ca     = "cacert.pem"; +    'cert' ="cert.pem", 
-$db->ssl_capath = null +    'ca' ="cacert.pem", 
-$db->ssl_cipher = null; +    'capath' =null 
 +    'cipher' =null 
 +    ] 
 +);
  
 /* /*
Line 65: Line 79:
 </code> </code>
  
 +==== Connecting To A Microsoft Azure MySQL Instance ====
 +<code php>
 +/*
 +* Enable ADOdb
 +*/
 +$db = newAdoConnection('mysqli');
  
-{{tag>[MySQL windows unix supported tier1]}}+$database = 'employees'; 
 +$host     = 'my-corporation.mysql.database.azure.com'; 
 +$user     = 'corpuser'; 
 +$password = 'Qzrt6r55geRt!'; 
 + 
 +$db->setConnectionParameter( 
 +    'ssl',  
 +    [ 
 +     'ca'=>'/opt/certs/DigiCertGlobalRootG2-combined.crt.pem' 
 +    ] 
 +); 
 + 
 +$db->setConnectionParameter( 
 +    'clientflags', MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT 
 +); 
 +  
 +/* 
 +* Open the connection 
 +*/ 
 +$db->connect($host, $user, $password, $database); 
 +</code> 
 + 
 +==== Forcing emulated prepared statements ==== 
 + 
 +ADOdb 5.22 introduced support for "true" bound variables in prepared statements((using  
 +[[https://www.php.net/manual/en/mysqli-stmt.execute.php|mysqli_stmt_execute()]],  
 +see [[https://github.com/ADOdb/ADOdb/pull/655|issue #655]])).  
 +Before that, parameterized queries were emulated, which was a potential security risk. 
 + 
 +When using database engines pretending to be MySQL but not implementing prepared statements such as 
 +[[https://clickhouse.com/|ClickHouse]] and  
 +[[https://manticoresearch.com/|Manticore Search]],  
 +it is possible((starting with ADOdb 5.22.8)) to force usage of emulated queries (i.e. reverting to behavior of ADOdb 5.21 and older) by setting the ''doNotUseBoundVariables'' property. 
 + 
 +<code php> 
 +$db = newAdoConnection('mysqli'); 
 +$db->doNotUseBoundVariables = true; 
 +$db->connect($host, $user, $password, $database); 
 +$db->execute($sql, $param); 
 +</code> 
 + 
 +{{tag>MySQL windows unix supported tier1}}
 {{htmlmetatags>metatag-keywords=(php, programming, database, mysql, percona, mariadb)}} {{htmlmetatags>metatag-keywords=(php, programming, database, mysql, percona, mariadb)}}
 +
v5/database/mysql.1579055931.txt.gz · Last modified: by mnewnham