1
votes

I get the following error when calling a 2nd stored procedure using PHP PDO:

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.

Normally this error occurs when you haven't used fetchAll() to get all the data back from MySQL before requesting more data. However in this case I am using fetchAll on all stored procedure calls.

Two workarounds are possible. Either use $stmt->closeCursor() after each stored procedure call or replace the stored procedures with SELECT queries instead.

Is there something about stored procedures that leaves data 'unfetched'?

1
Please post the stored procedure definitions. Do you SELECT multiple result sets in one of them, but only fetchAll() from one result set without using nextRowset() for example? - Michael Berkowski

1 Answers

0
votes

I had the same issue, I used a PDO fetchAll, nextRowset(); then closeCursor(); this solved my problem.