运算符

运算符 示例 结果
= $where['id'] = 5 id=5
> $where['id >'] = 5 id>5
< $where['id <'] = 5 id<5
>= $where['id >='] = 5 id>=5
<= $where['id <='] = 5 id<=5
!=,<> $where['id !'] = 5 id<>5
is null $where['id'] = null
$where['id'] = '`null`'
$where['id !'] = '`not null`'
id IS NULL
is not null $where['id !'] = null
$where['id !'] = '`null`'
$where['id'] = '`not null`'
id IS NOT NULL
between and $where['id ~'] = array(1,5) id BETWEEN 1 AND 5
in $where['id'] = array(1,3,5) id IN (1,3,5)
not in $where['id !'] = array(1,3,5) id NOT IN (1,3,5)
like $where['id %%'] = 'a'
$where['id %_'] = 'a'
$where['id _%'] = 'a'
id LIKE '%a%'
id LIKE '%a'
id LIKE 'a%'
not like $where['id !%%'] = 'a'
$where['id !%_'] = 'a'
$where['id !_%'] = 'a'
id NOT LIKE '%a%'
id NOT LIKE '%a'
id NOT LIKE 'a%'
regexp $where['id reg'] = '\^[a]'
$where['id reg_binary'] = '\^[a]'
id REGEXP '\^[a]'
id REGEXP BINARY '\^[a]'

逻辑运算符

逻辑运算符 示例 结果
and $where = array(
    'id'=> 5,
    'name'=>'nick'
)
id = 5 AND name = 'nick'
or $where = array(
    'id'=> 5,
    'or name'=>'nick'
)
id = 5 OR name = 'nick'
xor $where = array(
    'id'=> 5,
    'xor name'=>'nick'
)
id = 5 XOR name = 'nick'
混合使用and, or $where = array(
    'id'=> 5,
    '(nickname'=> 'nick',
    'or name)'=>'nick'
)
id = 5 AND ( nickname = 'nick'
OR name = 'nick')

使用*符号,忽略自动过滤

搜索字段是读取tabeljoin table信息来自动过滤字段的,假如join table里有自定义字段时前面加个*标识就可以忽略过滤

$where['or *a.name)'] = 'nick';     //name字段不会判断是否存在