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