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‘
时间: 2024-11-07 07:04:05