Laravel whereIn与Grammar.php第118行中的where子句ErrorException:

时间:2016-06-01 12:36:23

标签: php laravel laravel-5 eloquent

以下是我的laravel查询:

$statusCondition = '[1]';

$users = DB::table('user_tracking')
                 ->join('user_detail', 'user_tracking.user_id', '=', 'user_detail.id')
                 ->select('user_tracking.*', 'user_detail.gender', 'user_detail.username', 'user_detail.auth_provider')
                 ->where('user_tracking.art_id','=','1')
                 ->where('user_tracking.visit_start_date','>',DB::raw('NOW()-INTERVAL 24 HOUR'))
                 ->whereIn('user_tracking.status',$statusCondition)
                 ->get();

当我在使用whereIn然后给出以下错误时,任何人都可以帮助解决此问题:

ErrorException in Grammar.php line 118: Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in /var/sites/l/letsnurture.co.uk/public_html/demo/museum/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 315 and defined

1 个答案:

答案 0 :(得分:3)

$statusCondition应该是一个数组。

替换

$statusCondition = '[1]';

$statusCondition = [1];