I’m trying to improve performance on a volkszaehler.org implementation by enabling persistent DB connections. Having hacked included Doctrine’s
Connection class to have
PDO::ATTR_PERSISTENT => true, I’m getting the PDO error
General error: PDO::ATTR_STATEMENT_CLASS cannot be used with persistent PDO instances"
Is there any way to fix this?
You could pass your own PDO instance to Doctrine, setting the persistent connection yourself:
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass, array( PDO::ATTR_PERSISTENT => true )); $config = new \Doctrine\DBAL\Configuration(); $connectionParams = array( 'dbname' => 'mydb', 'user' => 'user', 'password' => 'secret', 'host' => 'localhost', 'pdo' => $dbh, ); $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
Be sure to know the implications of using persistent connections with PDO: What are the disadvantages of using persistent connection in PDO