title: Codeigniter: how do I select count when `$query->num_rows()` doesn't work for me?
body: <p>I have a query which is returning a sum, so naturally it returns <em><strong>one</strong></em> row.<br>
  I need to count the number of records in the DB which made that sum.</p>
  
  <p>Here's a sample of the type of query I am talking about (MySQL):</p>
  
  <pre><code>SELECT 
      i.id, 
      i.vendor_quote_id, 
      i.product_id_requested, 
      SUM(i.quantity_on_hand) AS qty, 
      COUNT(i.quantity_on_hand) AS count
  FROM vendor_quote_item AS i
  JOIN vendor_quote_container AS c 
      ON i.vendor_quote_id = c.id
  LEFT JOIN company_types ON company_types.company_id = c.company_id
  WHERE company_types.company_type =  'f'
  AND i.product_id_requested =  12345678
  </code></pre>
  
  <p>I have found and am now using the select_min(), select_max(), and select_sum() functions, but my <em>COUNT()</em> is still hard-coded in.</p>
  
  <p>The <em><strong>main</strong></em> problem is that I am having to specify the table name in a <em>tightly</em> coupled manner with something like <code>$this-&gt;$db-&gt;select( 'COUNT(myDbPrefix_vendor_quote_item.quantity_on_hand) AS count' )</code> which kills portability and makes switching environments a PIA.</p>
  
  <p>How can/should I get my the count values I am after with CI in an uncoupled way??</p>