Can Doctrine be used with persistent PDO connections?

I am trying to improve performance when implementing volkszaehler.org by including persistent database connections. After hacking, I included the Doctrine Connection class to have PDO::ATTR_PERSISTENT => true , I get a PDO General error: PDO::ATTR_STATEMENT_CLASS cannot be used with persistent PDO instances"

Is there any way to fix this?

+4
source share
1 answer

You can transfer your own PDO instance to Doctrine by establishing a 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 familiarize yourself with the consequences of using persistent connections with PDO: What are the disadvantages of using persistent connections in PDO

+12
source

All Articles