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

    /**
     * 查询展示信息
     * 
     */
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();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值