title: Codeigniter ActiveRecord duplicate,change,execute MySQL query
body: <p>I am using the ActiveRecord library that comes with the PHP framework CodeIgniter. I frequently find myself needing to query the database for a number of rows using a <code>LIMIT</code> clause, but also needing to know the total number of rows I would have pulled had I not included the <code>LIMIT</code> clause. For example, this is frequently the case when I provide pagenation for many results. I only want to pull 20 records at a time, but I also need to know how many rows there are in total which match my query where clause. I need to create 2 slightly different queries, a count query:</p>
  
  <pre><code>SELECT * FROM table WHERE [where_clause];
  </code></pre>
  
  <p>And a 'paged' query:</p>
  
  <pre><code>SELECT * FROM table WHERE [where_clause] LIMIT 0,20;
  </code></pre>
  
  <p>Is there an elegant solution to this problem with ActiveRecord? There doesn't seem to be anything out of the box which will help me. Obviously I can write around the problem with my own PHP but it would be ideal if I could take advantage of some aspect of the library to not have to duplicate code, etc.</p>