|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-02-05 19:15 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 13:00:01 2025 UTC |
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());