0
votes

when calling a stored procedure in zend framework 2 , it throwing an error message, how can i solve this issue ,

$dbAdapter = $e->getApplication()->getServiceManager()->get('Zend\Db\Adapter\Adapter');
    $results = $dbAdapter->query("CALL PROCEDURE_NAME('PARAM1')");
    $DataSource = $results->execute();
    $Statement = $DataSource->getResource();
    $Result = $Statement->fetchAll(\PDO::FETCH_OBJ);

the above code is using to get stored procedure information

getting below error

Statement could not be executed (HY000 - 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.)

1
Have a look at php.net/manual/en/ref.pdo-mysql.php and it will give you the information about your error. - Ukuser32
where i can add MYSQL_ATTR_USE_BUFFERED_QUERY above code? - Rathilesh C
Solved my problem , i just put closeCursor after fetching result - Rathilesh C

1 Answers

1
votes

Solved my problem , i just put closeCursor after fetching result

$dbAdapter = $e->getApplication()->getServiceManager()->get('Zend\Db\Adapter\Adapter');
$results = $dbAdapter->query("CALL PROCEDURE_NAME('PARAM1')");
$DataSource = $results->execute();
$Statement = $DataSource->getResource();
$Result = $Statement->fetch(\PDO::FETCH_OBJ);
$Statement->closeCursor();

Thank you Ukuser32 for supporting me to find solution