|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-02-19 12:07 UTC] tony2001@php.net
-Status: Open
+Status: Not a bug
[2014-02-19 12:07 UTC] tony2001@php.net
[2014-02-19 14:52 UTC] mikhail dot v dot gavrilov at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 20 15:00:01 2025 UTC |
Description: ------------ PDO MySQL not allow create multi connections from one PHP session Test script: --------------- #!/usr/bin/php <?php error_reporting(E_ALL); ini_set('display_errors','On'); $dsn = 'mysql:dbname=test;unix_socket=/var/lib/mysql/mysql.sock'; $user = 'root'; $pass = ''; $connection1 = new PDO( $dsn, $user, $pass, array( PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false, PDO::ATTR_AUTOCOMMIT => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) ); $connection2 = new PDO( $dsn, $user, $pass, array( PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false, PDO::ATTR_AUTOCOMMIT => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) ); $sth1 = $connection1->query('select 1'); $sth2 = $connection2->query('select 2'); unset($connection1); unset($connection2); echo("It's works"); ?> Expected result: ---------------- I am expected that I can send first query for connection1 and second query for connection2. But I see what still uses one connection :( Actual result: -------------- We have Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in /home/crmdev/www/bes/mysql_multi_connection_bug.php:35