ID: 47504 Comment by: admin at ifyouwantblood dot de Reported By: admin at ifyouwantblood dot de Status: Open Bug Type: PDO related Operating System: Windows XP SP 3 PHP Version: 5.2.8 New Comment:
also appears in 5.2.9 Previous Comments: ------------------------------------------------------------------------ [2009-02-25 21:07:16] admin at ifyouwantblood dot de Description: ------------ i get this error with following code: ------------- 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. HY000 #0 D:\_projects\web\1.php(13): PDO->query('INSERT INTO `te...') #1 {main} -------------- removing !SQL COMMENTS! will solve this. this only appears on windows (XP), linux is fine. mysql version is 5.0.51a. latest XAMPP package was used to test this (without modifications). Reproduce code: --------------- <?php set_exception_handler('ehandler'); $pdo=new PDO('mysql:dbname=barcodescanner;host=127.0.0.1','root',''); $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $pdo->query(' CREATE TABLE IF NOT EXISTS `test` ( `some` VARCHAR( 100 ) NOT NULL ) ENGINE = INNODB '); $pdo->query('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE'); $pdo->query('START TRANSACTION'); $pdo->query("INSERT INTO `test` (some) VALUES ('1111111111111111'), ('1111111111111'); -- I AM AN SQL COMMENT, REMOVING ME WILL SOLVE THIS PROBLEM"); $pdo->query("INSERT INTO `test` (some) VALUES ('1111111111111111'), ('1111111111111')"); $pdo->query('COMMIT'); function ehandler($exception) { echo '<pre>'."\r\n"; echo $exception->getMessage().' '.$exception->getCode(); echo "\r\n\r\n"; echo $exception->getTraceAsString(); echo '</pre>'; } Expected result: ---------------- nothing Actual result: -------------- 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. HY000 #0 D:\_projects\web\1.php(13): PDO->query('INSERT INTO `te...') #1 {main} ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47504&edit=1