The Pdo\Mysql class
A PDO subclass representing a connection using the MySQL PDO driver.
Intro
A PDO subclass representing a connection using the MySQL PDO driver.
This driver supports a dedicated SQL query parser for the MySQL dialect. It can handle the following:
- Single and double-quoted literals with both doubling and backslash as escaping mechanisms
- Backtick literals with doubling as escaping mechanism
- Two-dashes, C-style comments, and Hash-comments.
Class synopsis
Predefined Constants
Pdo\Mysql::ATTR_USE_BUFFERED_QUERYBy default all statements are executed in buffered mode. If this attribute is set to false on a
Pdo\Mysqlobject, the MySQL driver will use the unbuffered mode.Setting MySQL unbuffered mode
php<?php $pdo = new Pdo\Mysql("mysql:host=localhost;dbname=world", 'my_user', 'my_password'); $pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); $unbufferedResult = $pdo->query("SELECT Name FROM City"); foreach ($unbufferedResult as $row) { echo $row['Name'] . PHP_EOL; } ?>Pdo\Mysql::ATTR_LOCAL_INFILEEnable
LOAD LOCAL INFILE.NoteCan only be used in the
driver_optionsarray when constructing a new database handle.Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORYAllows restricting LOCAL DATA loading to files located in this designated directory.
Pdo\Mysql::ATTR_INIT_COMMANDCommand to execute when connecting to the MySQL server. Will automatically be re-executed when reconnecting.
Pdo\Mysql::ATTR_READ_DEFAULT_FILERead options from the named option file instead of from
my.cnf.NoteThis option is not available if mysqlnd is used, because mysqlnd does not read the mysql configuration files.
Pdo\Mysql::ATTR_READ_DEFAULT_GROUPRead options from the named group from
my.cnfor the file specified withPdo\Mysql::ATTR_READ_DEFAULT_FILE.NoteThis option is not available if mysqlnd is used, because mysqlnd does not read the mysql configuration files.
Pdo\Mysql::ATTR_COMPRESSEnable network communication compression.
Pdo\Mysql::ATTR_DIRECT_QUERYAlias
PDO::ATTR_EMULATE_PREPARES.Pdo\Mysql::ATTR_FOUND_ROWSReturn the number of found (matched) rows, not the number of changed rows.
Pdo\Mysql::ATTR_IGNORE_SPACEPermit spaces after SQL function names. Makes all SQL functions names reserved words.
Pdo\Mysql::ATTR_MAX_BUFFER_SIZEMaximum buffer size. Defaults to 1 MiB.
NoteThis constant is not supported when compiled against mysqlnd.
Pdo\Mysql::ATTR_MULTI_STATEMENTSDisables multi query execution in both
PDO::prepareandPDO::querywhen set to false.Pdo\Mysql::ATTR_SERVER_PUBLIC_KEYRSA public key file used with the SHA-256 based authentication.
Pdo\Mysql::ATTR_SSL_KEYThe file path to the SSL key.
Pdo\Mysql::ATTR_SSL_CERTThe file path to the SSL certificate.
Pdo\Mysql::ATTR_SSL_CAThe file path to the SSL certificate authority.
Pdo\Mysql::ATTR_SSL_CAPATHThe file path to the directory that contains the trusted SSL CA certificates, which are stored in PEM format.
Pdo\Mysql::ATTR_SSL_CIPHERA list of one or more permissible ciphers to use for SSL encryption, in a format understood by OpenSSL. For example:
DHE-RSA-AES256-SHA:AES128-SHAPdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERTProvides a way to disable verification of the server SSL certificate.
NoteThis option is available only with mysqlnd.
Mysql