php - Custom query for database in Laravel -


first of i'm wondering if possible in laravel?

i have code:

$master_array = $_post['master_search_array'];  $count = count($master_array); $master_string = '';  for($i=0; $i<$count; $i++) {     if($master_array[$i] == "dining"){         $master_string .= "where('dining', 'dining')";     }     if($master_array[$i] == "party"){         $master_string .= "where('party','party')";     }     ....etc point }  $tours = db::table('tours')->$master_string->get();  return $tours; 

so @ end should this:

$tours = db::table('tours')->where('dining', 'dining)->where('party','party')->get(); 

how can in laravel, gives me error, no matter if pass $master_string or {{$master_string}}.

there no need master string. use query builder how it's meant used...

    $master_array = $_post['master_search_array'];      $count = count($master_array);     $query = db::table('tours');      for($i=0; $i<$count; $i++) {         if($master_array[$i] == "dining"){             $query->where('dining', 'dining');         }         if($master_array[$i] == "party"){             $query->where('party', 'party');         }     }      $tours = $query->get();      return $tours; 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -