Welcome Guest, Not a member yet? Register   Sign In
Problem with query
#2

[eluser]CroNiX[/eluser]
Maybe check to see if your $categories is empty before adding it to the query?

Code:
$this->db
  //->select('*')    //don't really need this.  If you don't have a select it will select * by default
  //->from('table1') //don't really need this either.  It can be put in the "get" portion saving you another method call.
  ->join('table2', 'table1.category = table2.id', 'left')
  ->join('table3', 'table1.news= table3.id', 'left');

//only add the where_in if there are categories
if (count($categories))
{
  $this->db->where_in('category', $categories);
}

//Run the final query
$q = $this->db->get('table1'); //putting table name here is same as having a "from" but with less code


Messages In This Thread
Problem with query - by El Forum - 11-18-2012, 02:13 AM
Problem with query - by El Forum - 11-18-2012, 02:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB