laravel 查询数据库获取结果如何判断是否为空
来自:https://blog.csdn.net/weixin_39616995/article/details/80667372
以下三种方法都可以使用:
$users = DB::table('users')->where('id',$id)->get();
if ($users->first()) {
//
}
if (!$users->isEmpty()) {
//
}
if ($users->count()) {
//
}
最后由 Leo 编辑于2018年11月08日 22:23