Welcome Guest, Not a member yet? Register   Sign In
How can I do this with CodeIgniter
#3

[eluser]rip_pit[/eluser]
you can have a look there for every DB querying methods :
http://www.codeigniter.fr/user_guide/dat...ecord.html

You can use a ->join to query multiple tables using one unique query.
then use a simple foreach to filter the results and separate the cat.
Something like :

Code:
$this->db->select('blog.*, categories.id, categories.name');
$this->db->from( 'blog' );
$this->db->join( 'categories', 'categories.id = blog.cat_id', 'LEFT');
$this->db->order_by('blog.id','DESC');
$this->db->order_by('categories.name ','DESC');
$query = $this->db->get();

if ($query->num_rows() > 0)
{
  $results = $query->result();
  
  //do what filtering is needed
  foreach ($results as $key => $row) {
    echo $row->cat_id.', ';
  }

}
else
{
  $results = false;
}

return $results ;


Messages In This Thread
How can I do this with CodeIgniter - by El Forum - 10-13-2012, 01:08 PM
How can I do this with CodeIgniter - by El Forum - 10-13-2012, 02:13 PM
How can I do this with CodeIgniter - by El Forum - 10-13-2012, 03:25 PM
How can I do this with CodeIgniter - by El Forum - 10-14-2012, 12:25 PM
How can I do this with CodeIgniter - by El Forum - 10-14-2012, 03:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB