MySQL
mysqli driver
Specification
Alternatives
See Also
This is the preferred driver for connections to the following databases:
This driver uses the PHP mysqli interface and supports all table types, with full support for transactions and rollback when the table type supports it.
It replaces Legacy MySQL drivers (mysql, mysqlt and mysqlpo).
Starting with ADOdb 5.22, the mysqli driver requires the MySQL Native Driver (Mysqlnd)
Driver Specific Issues
renameColumnSql
The method renameColumnSql normally takes 3 parameters, $tableName
,
$oldColumnName
and $newColumnName
. When used with the mysql provider, a full definition of the column must be provided, as if creating the column new
Usage
/* * We are going to rename a column from col9 to col6. */ $flds = 'col6 C(50) NOTNULL DEFAULT "BILL"'; # Then create a data dictionary object, using this connection $dict = NewDataDictionary($db); $sql = $dict->renameColumnSql($table,'col9','col6', $flds);
Connecting With SSL
From ADOdb version 5.21, you can make an SSL connection to MySQL in the following way:
/* * Enable ADOdb */ $db = newAdoConnection('mysqli'); /* * Set the SSL parameters */ $db->ssl_key = "key.pem"; $db->ssl_cert = "cert.pem"; $db->ssl_ca = "cacert.pem"; $db->ssl_capath = null; $db->ssl_cipher = null; /* * Open the connection */ $db->connect($host, $user, $password, $database);
Connecting To A Microsoft Azure MySQL Instance
/* * Enable ADOdb */ $db = newAdoConnection('mysqli'); $database = 'employees'; $host = 'my-corporation.mysql.database.azure.com'; $user = 'corpuser'; $password = 'Qzrt6r55geRt!'; $db->ssl_ca = '/opt/azure-cert/DigiCertGlobalRootCA.crt.pem'; /* * Open the connection */ $db->connect($host, $user, $password, $database);
Forcing emulated prepared statements
ADOdb 5.22 introduced support for “true” bound variables in prepared statements2). 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
ClickHouse and
Manticore Search,
it is possible3) to force usage of emulated queries (i.e. reverting to behavior of ADOdb 5.21 and older) by setting the doNotUseBoundVariables
property.
$db = newAdoConnection('mysqli'); $db->doNotUseBoundVariables = true; $db->connect($host, $user, $password, $database); $db->execute($sql, $param);