php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57540 Problem - Error number 2014 - PDO, MySQL 5.0.33, ZF 0.7.0, PHP 5.2.1
Submitted: 2007-02-21 14:01 UTC Modified: 2008-09-12 13:13 UTC
From: drpajak at wp dot pl Assigned:
Status: Closed Package: PDO_MYSQL (PECL)
PHP Version: 5.2.1 OS: XP +SP2
Private report: No CVE-ID: None
 [2007-02-21 14:01 UTC] drpajak at wp dot pl
Description:
------------
PDO + ZF + Stored Procedure

Problem with execution two (or more) stored procedure in one function

Reproduce code:
---------------
$sql='CALL porcedure_1(1)';
$db = Zend::registry('db');	
$stmt = $db -> prepare($sql);
$stmt -> execute();
$row = $stmt->fetch();
$stmt->closeCursor();
$stmt=null;

$sql='CALL porcedure_2(1)';
$stmt = $db -> prepare($sql);
$stmt -> execute();
$row = $stmt->fetch();
$stmt->closeCursor();
$stmt=null;

print_r($row);exit;

Expected result:
----------------
results array

Actual result:
--------------
PDOException Object ( [message:protected] => 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-21 14:04 UTC] drpajak at wp dot pl
2
 [2007-02-21 15:35 UTC] drpajak at wp dot pl
I think, this is a problem with stored procedure +PDO beacause
when I make that:

$sql='SELECT * FROM table';
$db = Zend::registry('db');	
$stmt = $db -> prepare($sql);
$stmt -> execute();
$row = $stmt->fetch();
$stmt->closeCursor();
$stmt=null;

$sql='CALL porcedure_2(1)';
$stmt = $db -> prepare($sql);
$stmt -> execute();
$row = $stmt->fetch();
$stmt->closeCursor();
$stmt=null;

work everything 

when stored procedure is on first place - it doesn't work




ps - i apologize for my English
 [2007-02-22 10:30 UTC] drpajak at wp dot pl
Solution

i maked a class

class connectDB
{
        private static $dbConn;
	
	private function __construct ()
	{}

        public static function setConnection ( )
	{
	   $config = Zend::registry('config');
   	   self::$dbConn = Zend_Db::factory($config->db->adapter, $config->db->config->asArray());
	   return self::$dbConn; 
	} 
}

and before executing a procedure i make new db connection

$db = connectDB::setConnection() ;

it's work


I know it is not fairest solution, but I don't find better solution
 [2008-09-12 13:13 UTC] johannes at schlueters dot de
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

Should be fixed with 5.3 when using mysqlnd (--with-pdo-mysql=mysqlnd or official PHP windows builds)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC