满足多条件筛选,需要用到模糊查询,
把需要筛选的条件组装成数组的格式
$pid=[1,5,8],
$model=Db::name('video')->where($where)->order('create_time','desc')->field('id,image,video,title,pid');
if(!empty($pid)){
foreach($pid as $k=>$v)
{
$arr=[];
array_push($arr,$v);
array_push($arr,$v.'|%');
array_push($arr,'%|'.$v);
array_push($arr,'%|'.$v.'|%');
$model=$model->where(['pid'=>['like',$arr,'or']]);
}
}
$data = $model->select();
第一次查询出所有满足的数据,然后在复合查询表,这样就满足了多条件筛选
0条评论