• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
or_where() as first selection statement??

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.

$query1 = $this->db->get('mytable');
if( $query->num_results() > 0 ){
   foreach($query->result() as $row){
   return $this->db->get('parent_table');

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


you could always do something like this if the or_where doesn't work as the first

foreach($x as $y)
  if($i == 0)
    $this->db->where('bha', 'blah');
  } else {

or_where can be the first function because the inner working check if there are previous where parts or not.

But if i was you i would get all ids in a comma separated list and use the where_in method this only requires one function call.

Thank you both!!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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