我正在尝试通过启用持久数据库连接来提高volkszaehler.org实现的性能.黑客攻击包括Doctrine的Connection类以使PDO :: ATTR_PERSISTENT =>是的,我收到PDO错误一般错误:PDO :: ATTR_STATEMENT_CLASS不能用于持久性PDO实例“
有没有什么办法解决这一问题?
您可以将自己的PDO实例传递给Doctrine,自己设置持久连接:
$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);
请务必了解与PDO使用持久连接的含义:What are the disadvantages of using persistent connection in PDO