Total Complexity | 6 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
15 | final class Driver extends AbstractPdoDriver |
||
16 | { |
||
17 | 313 | public function createConnection(): PDO |
|
18 | { |
||
19 | 313 | $this->attributes += [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]; |
|
20 | |||
21 | 313 | if (PHP_VERSION_ID >= 80100) { |
|
22 | 313 | $this->attributes += [PDO::ATTR_STRINGIFY_FETCHES => true]; |
|
23 | } |
||
24 | |||
25 | 313 | $pdo = parent::createConnection(); |
|
26 | |||
27 | 313 | if ($this->charset !== null) { |
|
28 | 1 | $pdo->exec('SET NAMES ' . $pdo->quote($this->charset)); |
|
29 | } |
||
30 | |||
31 | 313 | if ($this->charset === null && !str_contains($this->dsn, 'charset')) { |
|
32 | 2 | $pdo->exec('SET NAMES ' . $pdo->quote('utf8mb4')); |
|
33 | } |
||
34 | |||
35 | 313 | return $pdo; |
|
36 | } |
||
37 | |||
38 | 420 | public function getDriverName(): string |
|
41 | } |
||
42 | } |
||
43 |