【发布时间】:2017-05-19 20:46:50
【问题描述】:
我使用elequent 进行查询我遇到whereIn 子句的问题,如果数组为空则不返回结果:
$idsUsers = empty(json_decode($data["idsUsers"])) ? null : json_decode($data["idsUsers"]);
$articles = DB::table('articles')
->whereIn('user_id',$idsUsers)
->orderBy('created_at','desc')
->paginate(10);
如何在 whereIn 方法中使用我的数组来检查它是否为空或 null
【问题讨论】:
-
Laravel 4 或 5.2,它们在查询方面有很多不同之处。
-
Laravel 4.2 ...
标签: laravel laravel-4 eloquent laravel-5.2