"Pdo\Mysql object is uninitialized" when opening a persistent connection #16314
Closed
Description
Description
The following code:
<?php
declare(strict_types=1);
$pdo = PDO::connect('mysql:host=127.0.0.1;dbname=test', 'root', '', [PDO::ATTR_PERSISTENT => true]);
$pdo->query('SELECT 1;');
Resulted in this output:
Fatal error: Uncaught Error: Pdo\Mysql object is uninitialized in /path/to/test.php on line 6
Error: Pdo\Mysql object is uninitialized in /path/to/test.php on line 6
Call Stack:
0.0001 395016 1. {main}() /path/to/test.php:0
0.0020 395152 2. PDO->query($query = 'SELECT 1;', $fetchMode = ???) /path/to/test.php:7
[1] 65142 bus error php test.php
But I expected this output instead: No error.
The error is gone if I either set PDO::ATTR_PERSISTENT
to false
or call the oldschool constructor (new PDO(…)
).
PHP Version
PHP 8.4-dev
Operating System
MacOS 15.0.1