相关疑难解决方法(0)

orWhere vs Where Laravel 5.1

我有以下代码:

$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()正确吗?

php sql laravel

3
推荐指数
1
解决办法
1139
查看次数

标签 统计

laravel ×1

php ×1

sql ×1