|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
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 EnglishSolution 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