I have been trying to get a result set from a stored procedure using PDO, but currently when make several call to the database it gives an error saying
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
Code:
$table = $data["TABLE_NAME"];// this returns table names like table_1,table_2
$exc = $conn->prepare("CALL Dummy_2('$table')");
$exc->execute();
while($finalRes = $exc->fetch(PDO::FETCH_ASSOC)) {
$ID = substr($table,11);
$exc2 = $conn->prepare("CALL sp_new('$ID')");
$exc2->execute();// the place which triggers the error
if(false !== $result) {
$totals = array();
while($row = $exc2->fetch(PDO::FETCH_ASSOC)) {
$tot = new stdClass();
$tot->count = (int)$row['cnt'];
$tot->ucount = (int)$row['ucnt'];
$tot->date = new DateTime($row['dat']);
$totals[] = $tot;
}
var_dump($tot);
}
}