本文实例讲述了thinkphp3.2框架中where条件查询用法。分享给大家供大家参考,具体如下:
thinkphp3.2 where 条件查询
在连贯操作中条件where的操作有时候自己很晕,所以整理下,有助于使用
查询条件
支持的表达式查询,tp不区分大小写
含义 | TP运算符 | SQL运算符 | 例子 | 实际查询条件 |
---|---|---|---|---|
等于 | EQ | = | $where['id'] = array('EQ','1') | id = 2 |
不等于 | NEQ | != | $where['id'] = array('NEQ','1') | id!=2 |
大于 | GT | > | $where['id'] = array('GT','1') | id >1 |
大于等于 | EGT | EGT | $where['id'] = array('EGT','1') | id>=1 |
小于 | < | < | $where['id'] = array('lt',1) | id < 1 |
小于等于 | <= | <= | $where['id'] = array('elt',1) | id<=1 |
匹配 | like | like | where[′id′]=array(′like′,′where[′id′]=array(′like′,′where['id'] = array('like','begin%') $where['id'] = array('like','%begin%') |
where id like '%begin' where id like 'begin%' where id like'%begin% |
在范围内包括俩端值 | between | 0<=id<=10 | $where['id'] = array('between',array('0','10')) | where id between 0 and 10 |
不在范围内 | not between | 0 >id and 1o < id | $where['id'] = array('not between',array('0','10')) | where id not between 0 and 10 |
在枚举的值中 | in | in | $where['id'] = array('in',array('1','2','5')) | where id in ('1','2','3') |
不在枚举值中 | not in | not in | $where['id'] = array('not in',array('1','2',5)) | where id not in ('1','2','5') |
exp | 表达式查询,支持SQL语法 |