title: PDO row count - num_rows equivalent
body: <p>I'm moving PHP code from mysql to ms sql server.
  This will execute my query:</p>
  
  <pre><code>  $r = $db_conn-&gt;prepare($sql);
    $r-&gt;execute();
  </code></pre>
  
  <p>Before I start processing, I need to count how many rows were returned.</p>
  
  <p>old code: </p>
  
  <pre><code>$r-&gt;num_rows;
  </code></pre>
  
  <p>new code:</p>
  
  <pre><code>$rows  = $r-&gt;fetchAll(PDO::FETCH_ASSOC);
  $rcount = count($rows);
  </code></pre>
  
  <p>All good, but when I try to access values from 1st row I'm getting nothing...</p>
  
  <pre><code>try {
      $row = $r-&gt;fetch(PDO::FETCH_ASSOC);
  } catch (Exception $ex) {   
      return 0;
  }   
  </code></pre>
  
  <p>I need to repoint to 1st row in my recordset after doing the count, how can I do this without having to requery the database again?</p>
  
  <p>I'm new to PHP, sorry for dumb and probably obvious question.
  Thanks in advance.</p>