我有以下代码:
$results = \DB::table('pack')
->Join('users as u1', 'u1.id', '=', 'pack.userid')
->Join('skills as s1', 's1.packid', '=', 'pack.packid')
->where('u_status', '=', "0")
->where('pack.amount', '<', 100)
->where('pack.amount', '>', 10)
->where('pack_status', '=', "2")
->where('pack.title', 'LIKE', "%$text%")
->orWhere('pack.description', 'LIKE', "%$text%")
->orWhere('pack.skills', 'LIKE', "%$text%")
->orWhere('s1.name', 'LIKE', "%$text%")
->orderBy('packid', 'desc')
->orderBy('featured', 'desc')
->groupBy('packid')
->take(40)
->get();
return $results;
Run Code Online (Sandbox Code Playgroud)
一切正常,除了->where('amount', '<', 100)和->where('amount', '>', 10)。
它不排除其中任何一个,并显示高于和低于我设定的数字的金额。如果我删除orWhere()它工作正常。
我使用orWhere()和where()正确吗?