Welcome Guest, Not a member yet? Register   Sign In
or_where() as first selection statement??
#1

[eluser]mtbkrdave[/eluser]
Hi All-

I'm using the Active Record Class, and I'd like to use the results from database query to select the rows for a second. I query one table for a list of key IDs, then I want to go back to the table to which the keys refer, and select all the original rows.

My question is: Can the $this->db->or_where() function be used as the first function in a series of select functions? I'd like to run through the first query using a foreach() loop, and with each pass through the loop add a new or_where() selection for the second query.

Code:
$this->db->where('id',$key_id);
$query1 = $this->db->get('mytable');
if( $query->num_results() > 0 ){
   foreach($query->result() as $row){
      $this->db->or_where('key',$row->id);
   }
   return $this->db->get('parent_table');
}

Is there a more-efficient way to do this??!

Thanks,
[medic]Dave


Messages In This Thread
or_where() as first selection statement?? - by El Forum - 12-15-2008, 09:49 PM
or_where() as first selection statement?? - by El Forum - 12-15-2008, 09:58 PM
or_where() as first selection statement?? - by El Forum - 12-16-2008, 02:48 AM
or_where() as first selection statement?? - by El Forum - 12-16-2008, 04:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB