Bug #66740 [NEW]: PDO MySQL not allow create multi connections from one PHP session
| From: | mikhail dot v dot gavrilov at gmail dot com | Date: | Wed, 19 Feb 2014 11:41:32 +0000 |
| Subject: | Bug #66740 [NEW]: PDO MySQL not allow create multi connections from one PHP session | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-184359@lists.php.net to get a copy of this message | ||
From: mikhail dot v dot gavrilov at gmail dot com
Operating system: Linux
PHP version: 5.5.9
Package: PDO MySQL
Bug Type: Bug
Bug description:PDO MySQL not allow create multi connections from one PHP session
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
--
Edit bug report at https://bugs.php.net/bug.php?id=66740&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66740&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66740&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66740&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66740&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66740&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66740&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66740&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66740&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66740&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66740&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66740&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66740&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66740&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66740&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66740&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66740&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66740&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66740&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66740&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66740&r=mysqlcfg