title: Count rows before adding a further limit statement CodeIgniter?
body: <p>I have ran into a problem...</p>
  
  <p>I have a bunch of where statments like so...</p>
  
  <pre><code>$this-&gt;db-&gt;where('Pool', "1");
  $this-&gt;db-&gt;where('Bedrooms &gt;=', "3");
  </code></pre>
  
  <p>Then a limit statement</p>
  
  <pre><code>$this-&gt;db-&gt;limit($limit, $offset);
  </code></pre>
  
  <p>And finally my get statement</p>
  
  <pre><code>$query = $this-&gt;db-&gt;get('table-name');
  </code></pre>
  
  <p><strong>My problem is I need to count the results before my limit statement, to get the total rows without the limit.. So I tried this..</strong></p>
  
  <pre><code>$this-&gt;db-&gt;where('Pool', "1");
  $this-&gt;db-&gt;where('Bedrooms &gt;=', "3");
  
  $num_rows = $this-&gt;db-&gt;count_all_results();
  
  $this-&gt;db-&gt;limit($limit, $offset);
  $query = $this-&gt;db-&gt;get('table-name');
  </code></pre>
  
  <p>This counts my rows with the where statements fine.. However, the get statement now gets records without the previous where statements working.</p>
  
  <p>It's not visible, but there is a large amount of code handling more where statements, and grabbing things in urls, So I'd prefer not to perform the retrieval of data twice in order to fix this...</p>
  
  <p>Cheers!</p>