Basically, I'm trying to select everything from a table using Query Builder if there's a record in another table that meets some conditions. At the moment I have the code below, however it's very slow on a table with 100K rows.
$result= [];
$customers = (array)DB::table('customers')->where('lastName','LIKE', Input::get('letter').'%')->orderBy('lastName','ASC')->get();
foreach($customers as $k => $v)
{
if(DB::table('orders')->where('disabled','=','')->where('customerId','=',$v->id)->where('status','!=',0)->count() > 0)
{
array_push($result, $v);
}
}
Any suggestions would be much appreciated! At the moment this times out after 5 minutes.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1J7hkHe
via IFTTT
Aucun commentaire:
Enregistrer un commentaire