1.只查询在某一个时间段的数据
$param = $this->request->post();
$b=array();
if(!empty($param[‘start_time‘]) && !empty($param[‘end_time‘])){ $b[‘create_time‘]=array(‘between‘,strtotime($param[‘start_time‘]).‘,‘.strtotime($param[‘end_time‘]));}
$StyleTypeModel = new StyleTypeModel();$result = Db::name(‘style_type‘) ->where($b) ->select();
2.查询多个条件的数据
$param = $this->request->post();$a=array();$b=array();$c=array();if(!empty($param[‘category‘])){ $a[‘type‘]=$param[‘category‘];}if(!empty($param[‘start_time‘]) && !empty($param[‘end_time‘])){ $b[‘create_time‘]=array(‘between‘,strtotime($param[‘start_time‘]).‘,‘.strtotime($param[‘end_time‘]));}if(!empty($param[‘keyword‘])){ $c[‘name‘]=$param[‘keyword‘];}$d=$a+$b+$c;$StyleTypeModel = new StyleTypeModel();$result = Db::name(‘style_type‘) ->where($d) ->select();
时间: 2024-10-17 11:33:13