Edit report at http://bugs.php.net/bug.php?id=50941&edit=1
ID: 50941 Updated by: u...@php.net Reported by: ies_clan at hotmail dot com Summary: pdo throws "unbuffered queries" error when use a sp and ATTR_EMULATE_PREPARES -Status: Open +Status: Bogus Type: Bug Package: PDO related Operating System: Windows XP home PHP Version: 5.3.1 New Comment: No bug here. Everything works fine if you use the API as you should. Your code lacks calls to stmt->nextrowset(): do { print_r($Query1->fetchAll()); } while ($Query1->nextrowset()); Previous Comments: ------------------------------------------------------------------------ [2010-02-05 19:15:01] ies_clan at hotmail dot com Description: ------------ if u call a stored procedure and then a normal sql statement, while u use ATTR_EMULATE_PREPARES = false, u got an error like: 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. to set PDO::MYSQL_ATTR_USE_BUFFERED_QUERY have no effect. uf u use closeCursor(); u got that error: Packets out of order Reproduce code: --------------- /* -- -- Table structure for table `testtabelle` -- DROP TABLE IF EXISTS `testtabelle`; CREATE TABLE `testtabelle` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Name` varchar(45) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; INSERT INTO `testtabelle` VALUES (1,'test'),(2,'test'),(3,'test'),(4,'test'),(5,'tesfsst'); DELIMITER $$ DROP PROCEDURE IF EXISTS `myTestProd` $$ CREATE PROCEDURE `myTestProd` () BEGIN SELECT * FROM testtabelle; END $$ DELIMITER ; */ $Database = new PDO('mysql:dbname='.DATABASE.';host='.DATABASE_SERVER, DATABASE_USER, DATABASE_PASSWORD, array( PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_PERSISTENT => false, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true ) ); $Query1 = $Database->prepare('CALL myTestProd()'); $Query1->execute(); print_r($Query1->fetchAll()); $Query1->closeCursor(); $Query2 = $Database->prepare('SELECT * FROM testtabelle'); $Query2->execute(); print_r($Query2->fetchAll()); $Query1->closeCursor(); Expected result: ---------------- Array ( [0] => Array ( [ID] => 1 [0] => 1 [Name] => test [1] => test ) [1] => Array ( [ID] => 2 [0] => 2 [Name] => test [1] => test ) [2] => Array ( [ID] => 3 [0] => 3 [Name] => test [1] => test ) [3] => Array ( [ID] => 4 [0] => 4 [Name] => test [1] => test ) [4] => Array ( [ID] => 5 [0] => 5 [Name] => tesfsst [1] => tesfsst ) ) Array ( [0] => Array ( [ID] => 1 [0] => 1 [Name] => test [1] => test ) [1] => Array ( [ID] => 2 [0] => 2 [Name] => test [1] => test ) [2] => Array ( [ID] => 3 [0] => 3 [Name] => test [1] => test ) [3] => Array ( [ID] => 4 [0] => 4 [Name] => test [1] => test ) [4] => Array ( [ID] => 5 [0] => 5 [Name] => tesfsst [1] => tesfsst ) ) Actual result: -------------- Array ( [0] => Array ( [ID] => 1 [0] => 1 [Name] => test [1] => test ) [1] => Array ( [ID] => 2 [0] => 2 [Name] => test [1] => test ) [2] => Array ( [ID] => 3 [0] => 3 [Name] => test [1] => test ) [3] => Array ( [ID] => 4 [0] => 4 [Name] => test [1] => test ) [4] => Array ( [ID] => 5 [0] => 5 [Name] => tesfsst [1] => tesfsst ) ) . Expected 1 received 11. Packet size=7 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=50941&edit=1