title: Multiple Select Count SQL queries in Codeigniter Active Record
body: <p>I like to convert following MySQL queries into Codeigniter Active Record Queries.</p>
  
  <p>Following is MySQL:</p>
  
  <pre><code>select brand_id,name,(select count(*) from items where brand_id = b.brand_id) as itemc, (select count(*) from models where brand_id = b.brand_id) as modelc from brands as b
  </code></pre>
  
  <p>Codeigniter :</p>
  
  <pre><code>$this-&gt;db-&gt;limit($perpage,$page);
      $query = 'select brand_id,name,(select count(*) from items where brand_id = b.brand_id) as itemc, (select count(*) from models where brand_id = b.brand_id) as modelc from brands as b limit '.$perpage.' offset '.$page.'';
      $query = $this-&gt;db-&gt;query($query);
      $query = $query-&gt;result();
      return $query;
  </code></pre>
  
  <p>Kindly help me to get the above codes converted for Codeigniter Active Record.</p>