我的查询就像
SELECT * FROM activities WHERE (active=1 AND linked_project_id IN (2,3) AND GLOBAL=1 OR (linked_project_id=2 AND active=1))
但我不知道如何把#linked; project_project_id = 2 AND active = 1'这里面和Laravel。 这是我的代码 -
$activities= Activitie::where('active','=',1)->whereIn('linked_project_id',array(2,3))->where('global','=','1')->orWhere('linked_project_id','='2)->where('active','=',1)->get();
但这会产生像
这样的结果SELECT * FROM activities WHERE (active=1 AND linked_project_id IN (2,3) AND GLOBAL=1 OR (linked_project_id=2 ) AND active=1)
答案 0 :(得分:1)
Model::where(function ($query) {
$query->where('a', '=', 1)
->orWhere('b', '=', 1);
})->where(function ($query) {
$query->where('c', '=', 1)
->orWhere('d', '=', 1);
});