如何用数组作为查询条件

2025-05-18 20:17:09
推荐回答(1个)
回答1:

使用数组作为查询条件
$User = M("User"); // 实例化User对象
$condition['name'] = 'thinkphp';
$condition['status'] = 1;
// 把查询条件传入查询方法
$User->where($condition)->select();
最后生成的SQL语句是
SELECT * FROM think_user WHERE `name`='thinkphp' AND status=1