• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple Categories

#2
[eluser]danmontgomery[/eluser]
Why not just do that in the query you're using to fetch the blog?

You haven't posted the model so I can't speculate what your query looks like, but it should be something like:

Code:
$this->db->select('Blog.*, GROUP_CONCAT(DISTINCT Category.CategoryName SEPARATOR ", ") AS categories', FALSE)
    ->join('BlogCategory', 'BlogCategory.BlogID = Blog.BlogID', 'left')
    ->join('Category', 'BlogCategory.CategoryID = Category.CategoryID', 'left')
    ->group_by('Blog.BlogID')
    ->order_by('Blog.BlogPostDate', 'DESC')
    ->limit(10)
    ->get('Blog');


Messages In This Thread
Multiple Categories - by El Forum - 08-04-2010, 07:10 AM
Multiple Categories - by El Forum - 08-04-2010, 07:25 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.