企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### where条件查询 ~~~ /** * 条件查询 */ public function where() { $model = new User(); $result = $model->where(['id', '=', 1])->select(); echo '查询id=1的用户:<br/>'; var_dump($result); $model = new User(); // 注意,是二维数组 and 查询 $where = [ // id在[1,2,3,4,5,6,7,8,9,10]内 ['id', 'in', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], // id不在[9,34] ['id', 'not in', [9, 34]], // age在[1,28]之间,包含 ['age', 'between', [1, 28]], // age不在[20,100]之间,包含 ['age', 'not between', [20, 100]], // city 是 NULL ['city', 'is', 'null'], // city 不是 NULL ['city', 'is not', 'null'], // id = 1 ['id', '=', 1], // username!=aaphp ['username', '!=', 'aaphp'], // id<=10 ['id', '<=', 10], // id>=30 ['id', '>=', 30], // username like %aaphp5% ['username', 'like', '%aaphp5%'], // username not like %aaphp% ['username', 'not like', '%aaphp%'], // id>1 ['id', '>', 1], // id<10 ['id', '<', 10], ]; $result = $model // 查询条件 ->where($where) // 执行查询 ->select(); echo "多条件查询:<br/>"; var_dump($result); } ~~~