Final Class Yiisoft\Db\Mysql\Driver
| Inheritance | Yiisoft\Db\Mysql\Driver » Yiisoft\Db\Driver\Pdo\AbstractPdoDriver |
|---|
Implements the MySQL, MariaDB driver based on the PDO (PHP Data Objects) extension.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| createConnection() | Yiisoft\Db\Mysql\Driver | |
| getDriverName() | Yiisoft\Db\Mysql\Driver |
Method Details
| public createConnection( ): PDO |
public function createConnection(): PDO
{
$this->attributes += [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_STRINGIFY_FETCHES => true,
];
$pdo = parent::createConnection();
if ($this->charset !== null) {
$pdo->exec('SET NAMES ' . $pdo->quote($this->charset));
} elseif (!str_contains($this->dsn, 'charset')) {
$pdo->exec('SET NAMES ' . $pdo->quote('utf8mb4'));
}
return $pdo;
}
Signup or Login in order to comment.