title: General error: 2014 Cannot execute queries while other unbuffered queries are active when calling a stored procedure
body: <p>What I am trying to do is get a product using:</p>
  <pre><code>$query = &quot;CALL GetAllProducts()&quot;;
  $statement = $this-&gt;connection-&gt;prepare($query);
  $statement-&gt;execute();
  return $statement;
  </code></pre>
  <p>and while I am looping through the results like this:</p>
  <pre><code>while ($row = $statement-&gt;fetch(PDO::FETCH_ASSOC)) {
      extract($row);
      ....
  }
  </code></pre>
  <p>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....</p>
  <p>Here is an example of how I get one of the on-to-many data:</p>
  <pre><code>$query = &quot;CALL GetProductImages(&quot; . $id . &quot;)&quot;;
  $statement = $this-&gt;connection-&gt;prepare($query);
  $statement-&gt;execute();
  </code></pre>
  <p>The issue I am having is I am getting this error:</p>
  <blockquote>
  <p>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.</p>
  </blockquote>
  <p>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.</p>
  <p>Thanks in advance!</p>