2016-04-07 29 views
-1

Lümende bir sorgum var. Ama bu çalışmıyor. Sorgu geçerli:Lumen'deki Mongo sorgusunu düzeltin

return Order::whereBetween('source_longitude', [$minLon_try_one, $maxLon_try_one]) 
     ->whereBetween('source_latitude',[51.365807806703,51.454384193297]) 
     ->where('status','=','pending') 
     ->where('created_at','<=', 2016-04-07 12:00:35) 
     ->where('created_at','>=', 2016-04-07 11:55:35) 
     ->orWhere(function($query) 
     { 
        $query->whereBetween('source_longitude', [51.321519613407, 51.498672386593]) 
        ->whereBetween('source_latitude',[35.612195271526,35.756086728473]) 
        ->where('status','=','pending') 
        ->where('created_at','<=',2016-04-07 11:55:35) 
        ->where('created_at','>=',2016-04-07 11:50:35); 
     } 
     )->get(); 

Ama sorgudan orWhere işlevini kaldırmak zaman Muhtemelen biraz yanlış orWhere kullanılarak

cevap

1

beklenen sonuç elde. Sorguyu düzgün bir şekilde yürütmek için nereye başka bir yere koymanız gerekir. Ne Artık yaptığını where a is 1 and b is 2 or (c is 3 and d is 4) gibi bir şey, ama bu bir deneyin o where (a is 1 and b is 2) or (c is 3 and d is 4)
böyle bir şey yapmak istiyorum, inan:

return Order::where(function ($query) { 
     $query->whereBetween('source_longitude', [$minLon_try_one, $maxLon_try_one]) 
      ->whereBetween('source_latitude', [51.365807806703, 51.454384193297]) 
      ->where('status', '=', 'pending') 
      ->where('created_at', '<=', '2016-04-07 12:00:35') 
      ->where('created_at', '>=', '2016-04-07 11:55:35'); 
    })->orWhere(function ($query) { 
     $query->whereBetween('source_longitude', [51.321519613407, 51.498672386593]) 
      ->whereBetween('source_latitude', [35.612195271526, 35.756086728473]) 
      ->where('status', '=', 'pending') 
      ->where('created_at', '<=', '2016-04-07 11:55:35') 
      ->where('created_at', '>=', '2016-04-07 11:50:35'); 
    })->get(); 
+0

sayesinde. Maalesef, her sipariş 20 dakika geçtikten sonra durum alanını nasıl güncelleyebilirim? – amirali