首页 > 代码库 > ThinkPHP运算符 与 SQL运算符 对照表
ThinkPHP运算符 与 SQL运算符 对照表
TP运算符 | SQL运算符 | 例子 | 实际查询条件 |
---|---|---|---|
eq | = | $map[‘id‘] = array(‘eq‘,100); | 等效于:$map[‘id‘] = 100; |
neq | != | $map[‘id‘] = array(‘neq‘,100); | id != 100 |
gt | > | $map[‘id‘] = array(‘gt‘,100); | id > 100 |
egt | >= | $map[‘id‘] = array(‘egt‘,100); | id >= 100 |
lt | < | $map[‘id‘] = array(‘lt‘,100); | id < 100 |
elt | <= | $map[‘id‘] = array(‘elt‘,100); | id <= 100 |
like | like | $map<‘username‘> = array(‘like‘,‘Admin%‘); | username like ‘Admin%‘ |
between | between and | $map[‘id‘] = array(‘between‘,‘1,8‘); | id BETWEEN 1 AND 8 |
not between | not between and | $map[‘id‘] = array(‘not between‘,‘1,8‘); | id NOT BETWEEN 1 AND 8 |
in | in | $map[‘id‘] = array(‘in‘,‘1,5,8‘); | id in(1,5,8) |
not in | not in | $map[‘id‘] = array(‘not in‘,‘1,5,8‘); | id not in(1,5,8) |
and(默认) | and | $map[‘id‘] = array(array(‘gt‘,1),array(‘lt‘,10)); | (id > 1) AND (id < 10) |
or | or | $map[‘id‘] = array(array(‘gt‘,3),array(‘lt‘,10), ‘or‘); | (id > 3) OR (id < 10) |
xor(异或) | xor | 两个输入中只有一个是true时,结果为true,否则为false,例子略。 | 1 xor 1 = 0 |
exp | 综合表达式 | $map[‘id‘] = array(‘exp‘,‘in(1,3,8)‘); | $map[‘id‘] = array(‘in‘,‘1,3,8‘); |
ThinkPHP Where 条件中使用表达式
原文出自: http://www.cnblogs.com/martin1009/archive/2012/08/24/2653718.html
ThinkPHP运算符 与 SQL运算符 对照表
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。