What I am trying to do is get a product using:
$query = "CALL GetAllProducts()";
$statement = $this->connection->prepare($query);
$statement->execute();
return $statement;
and while I am looping through the results like this:
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
extract($row);
....
}
I am also querying three different one-to-many relationships in the above while loop. I am getting a list of product variants, product images, and another one....
Here is an example of how I get one of the on-to-many data:
$query = "CALL GetProductImages(" . $id . ")";
$statement = $this->connection->prepare($query);
$statement->execute();
The issue I am having is I am getting this error:
Fatal error: Uncaught PDOException: 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.
I now want to use PDOStatement::fetchAll() to get all the one-to-many data to avoid the above error but I can't find a solution on how to use it.
Thanks in advance!