多字段查询,多条件查询写法

xiaoxiao2021-02-28  65

/** * 查询展示信息 * */ public function order(){ $data=I(); $uid=$_SESSION['id']; //print_r($_SESSION); if($uid==1){ $where=array(); }elseif($uid==2){ $where=array(); }elseif($uid==3){ $where=array(); }else{ $where=array('uid'=>$uid); } //print_r($data); $starttime=$data['starttime']; $endtime=$data['endtime']; $states=$data['states']; $searcher=$data['searcher']; if(!empty($starttime)){ //$this->timebegin = $starttime; //$this->bbs_forums->_serarch_type['dotimeBegin'] = $dotimeBegin; //$map['id'] = array('elt',100); $where['calltime']= array('egt',$starttime); } if(!empty($endtime)){ //$this->timeend = $endtime; //$this->bbs_forums->_serarch_type['dotimeBegin'] = $dotimeBegin; $where['calltime']= array($where['calltime'],array('elt',$endtime)); } //print_r($where);exit; if(!empty($states)){ //$this->gostates = $states; //$this->bbs_forums->_serarch_type['dotimeBegin'] = $dotimeBegin; $where['states']=$states; } if(!empty($searcher)){ //$this->gosearcher =$searcher; //$this->bbs_forums->_serarch_type['dotimeBegin'] = $dotimeBegin; //$where['customuser']=array('like',"%{$searcher}%"); //$where['tel']=array('like',"%{$searcher}%"); $where['_string'] ="(customuser like '%{$searcher}%') OR (tel like '%{$searcher}%') "; } //print_r($where);exit; $obj=M(); $total=$obj->table("custom")->where($where)->count(); $page=new \Think\Page($total,12,$parameter); $page->setconfig("prev","上一页"); $page->setconfig("next","下一页"); $arr=$obj->table("custom")->where($where)->order("calltime desc")->limit($page->firstRow,$page->listRows)->select(); $show=$page->show(); //echo $obj->getLastSql(); //print_r($arr); //exit; $prarr=$obj->table("province")->select(); $cityarr=$obj->table("city")->select(); $areaarr=$obj->table("area")->select(); $this->assign("uid",$uid)->assign("show",$show)->assign("prarr",$prarr)->assign("cityarr",$cityarr)->assign("areaarr",$areaarr)->assign("arr",$arr)->display(); }
转载请注明原文地址: https://www.6miu.com/read-78293.html

最新回复(0)