Details
-
Type:
Bug
-
Status:
Open
-
Priority:
N/A
-
Resolution: Unresolved
-
Affects Version/s: 1.6.2
-
Fix Version/s: None
-
Component/s: Zend_Db
-
Labels:None
Description
This bug is not fixed yet. Details: ZF v1.6.2, PHP v5.1.6, Mysql V5.0.45.
Irregardless of how PDO:MYSQL_ATTR_USE_BUFFERED_QUERY is set, or using fetchAll() if you run two store procedures you get the same error:
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.
Example code:
$registry = Zend_Registry::getInstance();
$tempdata = array();
$stmt = $registry->dbAdapter->query("CALL mgmtcomm_yearlybarchart('2008-01-01','2008-10-01')");
// Store results in array
$rows = $stmt->fetchAll();
foreach($rows as $row) {
$tempdata[] = number_format($row['data'],2);
$numrows++;
}
// Free DB Query resources
$stmt->closeCursor();
print_r($tempdata);
$stmt = $registry->dbAdapter->query("CALL mgmtcomm_yearlybarchart('2008-01-01','2008-10-01')");
// Store results in array
$rows = $stmt->fetchAll();
foreach($rows as $row) { $tempdata[] = number_format($row['data'],2); $numrows++; } }
// Free DB Query resources
$stmt->closeCursor();
print_r($tempdata);
Patrick Calkins writes:
Code:
$pdoParams = array( PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true ); $params = array( 'host' => '127.0.0.1', 'username' => 'webuser', 'password' => 'xxxxxx', 'dbname' => 'test', 'driver_options' => $pdoParams ); $db = Zend_Db::factory('Pdo_Mysql', $params); // Stored procedure returns a single row $stmt = $db->prepare('CALL get_customer_by_id(:customerId)'); $stmt->bindParam('customerId', $customerId, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetchAll(); print_r($result); $stmt->closeCursor(); // Stored procedure returns a single row $stmt = $db->prepare('CALL get_address_by_id(:customerId)'); $stmt->bindParam('customerId', $customerId, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetchAll(); print_r($result);This will consistently throw this error: '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.'If you insert $stmt->nextRowset(); before $stmt->closeCursor(); it will
throw this error: 'SQLSTATE[HYC00]: Optional feature not implemented'This appears to be a bug, and I haven't found any more info as to its status
lately. Is this correct??
Assigning to Ralph to get closure on this issue.