title: PHP PDO: nextRowset on multiple rowsets on a prepared statement
body: <p>I have the PHP script below which uses PDO to prepare and call a MySQL stored procedure. The stored procedure returns 2 rowsets. The 1st contains 25 rows. The 2nd contains 1 row. I can't seem to get the nextRowset to fetch the 2nd rowset. I know the stored procedure works because it was working when I was using mysqli_next_result. Thanks...</p>
  
  <p>1.) What am I doing wrong?</p>
  
  <p>2.) Is there a more efficient or secure way to write this script? I use the same format for all my ajax calls. I know I can bind the $_GET parameters to a data type (string, integer) to be a little more secure but the stored procedure already does that.</p>
  
  <pre><code>&lt;?php
  header('Content-type: application/json');
  session_start();
  if(isset($_SESSION['Logged_In'])){
      $r=array();
      require('db.inc');
      $s=$c-&gt;prepare("CALL get_records({$_SESSION['User_ID']},?,?,?)");
      $s-&gt;execute($_GET);
      do{$r[]=$s-&gt;fetchAll(PDO::FETCH_NUM);}while($s-&gt;nextRowset());
      $c=null;
      echo json_encode($r);
  }
  ?&gt;
  </code></pre>