[eluser]cristian_c[/eluser]
Is there a better way to do this. This is working ok, but I'm thinking there has to be a better way.
Basically I need to add the comments to the result of the blogs query.
Am I breaking any standards or rules by having a $this->getComments($post['id']); inside a foreach?
Code:
function getBlogs()
{
$query = $this->db->get('blogs');
$result = $query->result_array();
foreach($result as $i => $blog){
$result[$i]['comments'] = $this->getComments($post['id']);
}
return $result;
}
function getComments($church_id)
{
$this->db->where('post_id',$post_id);
$query = $this->db->get('comments');
return $query->result_array();
}