比如查询一个时间范围内容的数据,并且desc字段不能等于null或者"",代码如下:

$where = $whereOr = [];
$where[] = ['time','>=',$start_time];
$where[] = ['time','<=',$end_time];
$whereOr[] = ['desc','=',null];
$whereOr[] = ['desc','=',""];

$data = Db::table('test')->where($where)->where(function ($query) use ($whereOr){
     $query->whereOr($whereOr);
})->select();
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐