首页 >后端开发 >php教程 >php多条件查询

php多条件查询

WBOY
WBOY原创
2016-06-23 13:26:141233浏览

 

$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