The Pdo\Mysql class
(PHP 8 >= 8.4.0)
简介
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.
 
类摘要
string
$dsn,?string
$username = null,#[\SensitiveParameter] ?string
$password = null,?array
$options = null)
string
$dsn,?string
$username = null,#[\SensitiveParameter] ?string
$password = null,?array
$options = null): static
$query, ?int $fetchMode = PDO::FETCH_COLUMN, int $colno): PDOStatement|falsestring
$query,?int
$fetchMode = PDO::FETCH_CLASS,string
$classname,array
$constructorArgs): PDOStatement|false
$query, ?int $fetchMode = PDO::FETCH_INTO, object $object): PDOStatement|false预定义常量
Pdo\Mysql::ATTR_USE_BUFFERED_QUERY- 
      
       By default all statements are executed in
       buffered mode.
       If this attribute is set to 
falseon a Pdo\Mysql object, the MySQL driver will use the unbuffered mode.示例 #1 Setting MySQL unbuffered mode
<?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_INFILE- 
      
       Enable 
LOAD LOCAL INFILE.注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY- 
      
       Allows restricting LOCAL DATA loading to files located in this
       designated directory.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_INIT_COMMAND- 
      
       Command to execute when connecting to the MySQL server.
       Will automatically be re-executed when reconnecting.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_READ_DEFAULT_FILE- 
      
       Read options from the named option file instead of from
       my.cnf.
      
      
注意: This option is not available if mysqlnd is used, because mysqlnd does not read the mysql configuration files.
 Pdo\Mysql::ATTR_READ_DEFAULT_GROUP- 
      
       Read options from the named group from my.cnf or
       the file specified with
       
Pdo\Mysql::ATTR_READ_DEFAULT_FILE.注意: This option is not available if mysqlnd is used, because mysqlnd does not read the mysql configuration files.
 Pdo\Mysql::ATTR_COMPRESS- Enable network communication compression.
 Pdo\Mysql::ATTR_DIRECT_QUERY- 
      
       别名 
PDO::ATTR_EMULATE_PREPARES. Pdo\Mysql::ATTR_FOUND_ROWS- 
      
       Return the number of found (matched) rows,
       not the number of changed rows.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_IGNORE_SPACE- 
      
       Permit spaces after SQL function names.
       Makes all SQL functions names reserved words.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_MAX_BUFFER_SIZE- 
      
       Maximum buffer size. Defaults to 1 MiB.
      
      
注意: This constant is not supported when compiled against mysqlnd.
 Pdo\Mysql::ATTR_MULTI_STATEMENTS- 
      
       Disables multi query execution in both
       PDO::prepare() and
       PDO::query() when set to 
false.注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_SERVER_PUBLIC_KEY- 
      
       RSA public key file used with the SHA-256 based authentication.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_SSL_KEY- 
      
       The file path to the SSL key.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_SSL_CERT- 
      
       The file path to the SSL certificate.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_SSL_CA- 
      
       The file path to the SSL certificate authority.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_SSL_CAPATH- 
      
       The file path to the directory that contains the trusted
       SSL CA certificates,
       which are stored in PEM format.
      
      
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_SSL_CIPHER- 
      
       A 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-SHA注意: Can only be used in the
driver_optionsarray when constructing a new database handle. Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERT- 
      
       Provides a way to disable verification of the server SSL certificate.
      
      
注意: This option is available only with mysqlnd.
注意: Can only be used in the
driver_optionsarray when constructing a new database handle. 
目录
- Pdo\Mysql::getWarningCount — Returns the number of warnings from the last executed query