TP5 where多条件查询

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
likelike$map<'username'> = array('like','Admin%');username like 'Admin%'
betweenbetween and$map['id'] = array('between','1,8');id BETWEEN 1 AND 8
not betweennot between and$map['id'] = array('not between','1,8');id NOT BETWEEN 1 AND 8
inin$map['id'] = array('in','1,5,8');id in(1,5,8)
not innot 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)
oror$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');

评论 (4)

  • infilky Reply

    Aug 26 2021 05:45 pm
  • infilky Reply

    Aug 01 2021 09:00 pm
  • Sceloduffcelf Reply

    Jul 05 2021 08:34 pm
  • neeries Reply

    涉及广告推广,审核未通过

    Dec 13 2020 11:20 am

发表评论