我无法雄辩地重现此查询。
我如何能毫无雄辩地进行查询?
select * from points where operator = 2 and (month(date) = '1' and day(date) >= 25 or month(date) = '2' and day(date) <= 24)
答案 0 :(得分:0)
考虑到您拥有Point
表的points
模型,下面的雄辩查询应该可以工作:
<?php
$points = Point::where('operator', 2)->where(function($q){
return $q->whereMonth('date', '=', 1)->whereDay('date', '>=', 25);
})->orWhere(function($q){
return $q->whereMonth('date', '=', 2)->whereDay('date', '<=', 24);
})->get();
答案 1 :(得分:0)
您可以为此使用DB Facade。.
$query = "select * from points where operator = :operator and (month(date) = :monthDate and day(date) >= :dayDate or month(date) = :monthDate2 and day(date) <= :dayDate2)"
$points = DB::select($query,[
"operator" => 2,
"monthDate" => 1,
"dayDate" => 25,
"monthDate2" => 2,
"dayDate2" => 24
])