先来看看判断语句
标签 | 含义 |
---|---|
eq或者 equal | 等于 |
neq 或者notequal | 不等于 |
gt | 大于 |
egt | 大于等于 |
lt | 小于 |
elt | 小于等于 |
heq | 恒等于 |
nheq | 不恒等于 |
比如现在我们想查询一条没有过期的优惠卷
首先我们要先得到现在的时间$time作为判断根据
其次数据表中要有优惠卷到期的日期coupon_endtime
然后在数据表中查询代码可以这样写
$coupon=M('coupon');//M()函数是初始数据库中的数据表对象$where['coupon-endtime']=array('egt',$time);$result=$coupon->where($where)->select();$this->ajaxReturn($result);
也可以这样写
用来查询一个时间段
$endtime='9000-00-00 00:00:00';$where['coupon_time']=array('between',$time,$endtime));//$time是时间段的开始时间,endtime是时间段的结束时间
一般情况下判断条件where这样写
$where[ '字段名 ' ]=array('判断语句','判断条件' ),判断语句就是上面的表格内容;