Welcome Guest, Not a member yet? Register   Sign In
[solved] Comment Counting Again
#2

[eluser]darkhouse[/eluser]
change your get_entries sql to this:

Code:
function getEntries()
{
    $this->db->select('e.*, COUNT(c.entry_ID) AS total_comments');
    $this->db->join('comments c', 'c.entry_ID = e.id');
    $this->db->group_by('c.entry_ID');
    $query['entries'] = $this->db->get('entries e');    
    return $query;
}

you should now have a new property in your row object called total_comments which should be the count of all comments for each blog entry.


Messages In This Thread
[solved] Comment Counting Again - by El Forum - 02-18-2009, 05:03 PM
[solved] Comment Counting Again - by El Forum - 02-19-2009, 02:14 AM
[solved] Comment Counting Again - by El Forum - 02-19-2009, 09:08 AM
[solved] Comment Counting Again - by El Forum - 02-19-2009, 07:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB