查询条件Where

1、字符串

$condition = 'name=\'Lily\' and age>10';

2、数组

['type' => 1, 'status' => 1] 
//生成 
(type = 1) AND (status = 1)
['id' => [1, 2, 3], 'status' => 0]
//生成 
(id IN (1, 2, 3)) AND (status = 0)
['status' => null]
//生成 
status IS NULL
['and', 'id=1', 'type=1']
// 生成 
id=1 AND type=1
['and', 'type=1', ['or', 'id=1', 'id=2']]
//生成
type=1 AND (id=1 OR id=2)
['between', 'id', 1, 10]
//生成 
id BETWEEN 1 AND 10
['in', 'id', [1, 2, 3]]
//生成 
id IN (1, 2, 3)
['like', 'name', 'aa'] 
//生成 
name LIKE '%aa%'
['like', 'name', ['aa', 'bb']]
//生成 
name LIKE '%aa%' AND name LIKE '%bb%'
['like', 'name', '%aa', false]
//生成 
name LIKE '%aa'

 

['or', ['name'=>'b'], ['name'=>'b']]
//生成 
name='a' or name='b'

 

posted @ 2015-10-22 17:06  慕尘  阅读(301)  评论(0编辑  收藏  举报