laravel中的whereNull和whereNotNull

whereNull 相当于 is null

whereNotNull相当于is not null

举个例子

这是数据库中的lara表

$res = DB::table('lara')->whereNull('uname')->get();
dd($res);

本条语句输出结果为 id=6的一条数据 也就是uname字段为空值的那条数据

$res = DB::table('lara')->whereNotNull('uname')->get();
dd($res);

本条语句输出的结果为数据表中的第1--5条数据  1--5条数据的uname字段都不为空

posted @ 2019-08-18 19:51  一颗糊涂淡  阅读(16126)  评论(0编辑  收藏  举报