首頁  >  文章  >  後端開發  >  php多条件查询

php多条件查询

WBOY
WBOY原創
2016-06-23 13:26:141209瀏覽

 

$sql="select *from think_kaoqin WHERE(1=1)";      if(!empty($uid))            {                $sql .=" and uid= ".$uid;            }             if(!empty($time1) && empty($time2))            {                                   $sql .=" and riqi >= '".$time1."'";            }            if (!empty($time2) &&empty($time1)) {                           $sql .=" and riqi <= '".$time2."'";            }           if (!empty($time1) && !empty($time2)) {                $sql .=" and riqi >= '".$time1."' and riqi <='".$time2."'";            }  $this->info=M('kaoqin')->query($sql);

 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn