[eluser]OES[/eluser]
You can achive your counts with SQL. Just look up mysql COUNT in google. And you would need GROUP also.
You can still use Active recored to get your results.
Here is an example I used to count comments per news ID.
Code:
function list_entries($limit, $cat='', $pag='', $app)
{
$this->db->select("ci_newsentries.*, ci_newscategories.newscategory_title AS catname, ci_newscategories.newscategory_title_sef AS caturl, COUNT(ci_newscomments.newscomment_id) AS no_comments");
$this->db->from('ci_newsentries');
$this->db->join('ci_newscomments', 'ci_newsentries.newsentry_id = ci_newscomments.newscomment_newsentry_id', 'left');
$this->db->join('ci_newscategories', 'ci_newsentries.newsentry_category = ci_newscategories.newscategory_id', 'left');
$this->db->where('ci_newsentries.newsentry_approved', $app);
if ($cat):
$this->db->where('ci_newsentries.newsentry_category', $cat);
endif;
$this->db->group_by("ci_newsentries.newsentry_id");
$this->db->order_by("ci_newsentries.newsentry_date", "desc");
$this->db->limit($limit, $pag);
$query = $this->db->get();
return $query->result_array();
} // list_entries()
This should hopefully get you on your way.