title: How to get the SQL_CALC_FOUND_ROWS value using prepared statements?
body: <p>I'm currently scratching my head at how to implement <code>SQL_CALC_FOUND_ROWS</code> with prepared statements.</p>
  
  <p>I'm writing a pagination class and obviously i want to add LIMIT to the query but also find what the total number of rows would be.</p>
  
  <p>Here's an example from the class in question.</p>
  
  <pre><code>$query = "select SQL_CALC_FOUND_ROWS id,title,location,salary,employer from jobs where region=38 limit 0,3";
  
  if($stmt = $connection-&gt;prepare($query)) {
      $stmt-&gt;execute()or die($connection-&gt;error); //execute query
      $stmt-&gt;bind_result($id,$title,$location,$salary,$employer,$image);
      while($stmt-&gt;fetch()){
          $jobs[$x]['id']=$id;
          $jobs[$x]['title']=$title;
          $jobs[$x]['location']=$location;
          $jobs[$x]['salary']=$salary;
          $jobs[$x]['employer']=$employer;
          $jobs[$x]['image']=$image;
          $x++;
      }
      $stmt-&gt;close();//close statement
  }
  </code></pre>
  
  <p>I'm a bit stumped as to how to get the <code>SQL_CALC_FOUND_ROWS</code> actual value? I had thought adding in something like:</p>
  
  <pre><code>$stmt-&gt;store_result();
  $count=$stmt-&gt;num_rows;
  </code></pre>
  
  <p>But that only gives a number based on the LIMIT, so in the above example its 3 rather than the full 6 that it should be.</p>