[eluser]Jonas G[/eluser]
Also: Is there a good way to count the number of comments a blog entry has without running a query for every entry? Before I switched to IR I would add
Code:
if ($get_comment_count) {
$comment_table = $this->config->item('comments_table');
$this->db->select('COUNT('.$comment_table.'.id) as comment_count', false);
$this->db->join($comment_table, $comment_table.'.parent_id = '.$table.'.id', 'left');
}
To my model function, but can't seem to get around this using IR.
On the same note, is there any way to 'add' and entry to the object array. eg. I run
Code:
$data['blogs'] = $this->blog->limit(25)->find_all();
foreach ($data['blogs'] as $b) {
$data['comment_count'][$b->id] = $b->related('comments')->count();
}
But I would much rather be able to 'add' 'comment_count' to each $data['blogs'].
Anyways - I hope you know what I mean - it's getting late.
/Jonas