天天看點

laravel Eloquent whereIn 多個字段

Eloquent whereIn 方法隻能加一個字段:

whereIn(string $column, mixed $values, string $boolean = ‘and’, bool $not = false)

詳情請看源碼:https://github.com/laravel/framework/blob/5.2/src/Illuminate/Database/Query/Builder.php#L893

解決辦法:使用 whereRaw 原生方法

$data = DB::whereRaw("(a,b,…) in ((1,2,…),(3,4,…),(5,6,…),(7,8,…)…)")->get();

ps:如果有更好的方法請留言!