3.2.4 运算符
系统对常用运算符的使用进行了二次封装,使用方便、快捷。
gt : 大于(>)
egt : 大于等于(>=)
lt : 小于(<)
elt : 小于等于(<=)
eq : 等于(=)
neq : 不等于(!=)
notlike : NOT LIKE
like : 同sql中的LIKE
between:同sql中的BETWEEN
[not] in:同sql中的 [NOT] IN
示例:
//
为便于演示,这里将所有运算符的使用均罗列出来,以下代码不可直接运行
$condition=array()
// uid > 5
$condition
[
'uid'
] = array(
'gt'
,
5
);
// uid < 5
$condition
[
'uid'
] = array(
'lt'
,
5
);
// uid = 5
$condition
[
'uid'
] = array(
'eq'
,
5
);
// uid >= 5
$condition
[
'uid'
] = array(
'egt'
,
5
);
// uid <= 5
$condition
[
'uid'
] = array(
'elt'
,
5
);
// uid
在3,5,19之间一个或多个
$condition
[
'uid'
] = array(
'in'
,
'3,5,19'
);
// uid
是3,5,19中的任何值
$condition
[
'uid'
] = array(
'not in'
,
'3,5,19'
);
// 5 <= uid <= 19
$condition
[
'uid'
] = array(
'between'
,
'5,19'
);
//product_name like 'a%'
$condition
[
'product_name'
] = array(array(
'like'
,
'a%'
));
// product_name like 'a%' or product_name like 'b%'
$condition
[
'product_name'
] = array(array(
'like'
,
'a%'
),array(
'like'
,
'b%'
),
'or'
);
//
会员昵称或姓名有一个含有shopnc字样的即可满足
$condition
[
'member_name|member_trname'
] = array(array(
'like'
,
'%shopnc%'
));
//
会员昵称或姓名都必须含有shopnc字样的才可满足
$condition
[
'member_name&member_trname'
] = array(array(
'like'
,
'%shopnc%'
));
//
以上各条件默认均是 "AND" 关系,即每个条件都需要满足,如果想满足一个即可( "OR" 关系),可增加以下条件
$condition
[
'_op'
] =
'or'
;
//
最后将以上条件传入where方法
$list
=
Model
(
TABLE
)->
where
(
$condition
)->
select
();
Copyright ©2009 - 2014 shopnc.net.All rights reserved.
Powered By ShopNC