Welcome Guest, Not a member yet? Register   Sign In
How to use attributes in controller or model?
#6

[eluser]Iciclefeet[/eluser]
I'm not sure what your going for but Ill take another crack at it.. Hope this helps
Code:
//Pull all categories for each post
//or for one post
public function Categories_for_post($post_id=null) {
      $this->db->select("GROUP_CONCAT(`categories`.`cat_name`) AS cat_name_list,cat_rel.post_id",FALSE)//Get all cat_name per post_id
                     ->from('categories')
                     ->join('cat_rel','categories.cat_id = cat_rel.cat_id','LEFT');
    if(!empty($post_id)//If Post id is set
       $this->where(array('cat_rel.post_id'=>$post_id);

              $q=$this->group_by("cat_rel.post_id")
                     ->get();

  if(!$q->num_rows())//No rows
    return NULL;

  return $q->result_array();      
}
Thats all i could think of, something in there might be helpful


Messages In This Thread
How to use attributes in controller or model? - by El Forum - 04-16-2012, 06:43 AM
How to use attributes in controller or model? - by El Forum - 04-16-2012, 07:34 AM
How to use attributes in controller or model? - by El Forum - 04-16-2012, 07:41 AM
How to use attributes in controller or model? - by El Forum - 04-16-2012, 07:44 AM
How to use attributes in controller or model? - by El Forum - 04-16-2012, 08:20 AM
How to use attributes in controller or model? - by El Forum - 04-16-2012, 10:44 AM
How to use attributes in controller or model? - by El Forum - 04-17-2012, 01:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB