(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:
public getWarningCount(): int
$dsn,$username = null,$password = null,$options = nullpublic PDO::beginTransaction(): bool
public PDO::commit(): bool
public static PDO::connect( string $dsn, ?string $username = null, #[\SensitiveParameter] ?string $password = null, ?array $options = null ): static
public PDO::errorCode(): ?string
public PDO::errorInfo(): array
public PDO::exec(string $statement): int|false
public PDO::getAttribute(int $attribute): mixed
public static PDO::getAvailableDrivers(): array
public PDO::inTransaction(): bool
public PDO::lastInsertId(?string $name = null): string|false
public PDO::prepare(string $query, array $options = []): PDOStatement|false
public PDO::query(string $query, ?int $fetchMode = null): PDOStatement|false
public PDO::query(string $query, ?int $fetchMode = PDO::FETCH_COLUMN, int $colno): PDOStatement|false
public PDO::query( string $query, ?int $fetchMode = PDO::FETCH_CLASS, string $classname, array $constructorArgs ): PDOStatement|false
public PDO::query(string $query, ?int $fetchMode = PDO::FETCH_INTO, object $object): PDOStatement|false
public PDO::quote(string $string, int $type = PDO::PARAM_STR): string|false
public PDO::rollBack(): bool
public PDO::setAttribute(int $attribute, mixed $value): bool}
Pdo\Mysql::ATTR_USE_BUFFERED_QUERYfalse on a Pdo\Mysql object, the MySQL driver will use the unbuffered mode. Example #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_INFILELOAD LOCAL INFILE. Note: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORYNote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_INIT_COMMANDNote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_READ_DEFAULT_FILENote: This option is not available if mysqlnd is used, because mysqlnd does not read the mysql configuration files.
Pdo\Mysql::ATTR_READ_DEFAULT_GROUPPdo\Mysql::ATTR_READ_DEFAULT_FILE. Note: This option is not available if mysqlnd is used, because mysqlnd does not read the mysql configuration files.
Pdo\Mysql::ATTR_COMPRESSPdo\Mysql::ATTR_DIRECT_QUERYPDO::ATTR_EMULATE_PREPARES. Pdo\Mysql::ATTR_FOUND_ROWSNote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_IGNORE_SPACENote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_MAX_BUFFER_SIZENote: This constant is not supported when compiled against mysqlnd.
Pdo\Mysql::ATTR_MULTI_STATEMENTSfalse. Note: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_SERVER_PUBLIC_KEYNote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_SSL_KEYNote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_SSL_CERTNote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_SSL_CANote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_SSL_CAPATHNote: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_SSL_CIPHERDHE-RSA-AES256-SHA:AES128-SHA Note: Can only be used in the
driver_optionsarray when constructing a new database handle.
Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERTNote: This option is available only with mysqlnd.
Note: Can only be used in the
driver_optionsarray when constructing a new database handle.
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/class.pdo-mysql.php