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
v5:database:mysql [2023/05/10 09:41] – [mysqli driver] mysqlnd required since 5.22 dregadv5:database:mysql [2024/04/30 13:07] (current) – Forcing emulated prepared statements dregad
Line 60: Line 60:
 * Enable ADOdb * Enable ADOdb
 */ */
-$db = newAdoConnection('mysqli')+$db = newAdoConnection('mysqli');
 /* /*
 * Set the SSL parameters * Set the SSL parameters
Line 81: Line 81:
 * Enable ADOdb * Enable ADOdb
 */ */
-$db = newAdoConnection('mysqli')+$db = newAdoConnection('mysqli');
  
 $database = 'employees'; $database = 'employees';
Line 94: Line 94:
 */ */
 $db->connect($host, $user, $password, $database); $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> </code>
  
 {{tag>[MySQL windows unix supported tier1]}} {{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.txt · Last modified: 2024/04/30 13:07 by dregad