ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
更多查看 [链式操作](https://www.kancloud.cn/a173512/thinkphp6/2452932) [查询表达式](https://www.kancloud.cn/a173512/thinkphp6/2452933) ## **where** 表达式查询是官方推荐使用的查询方式 ~~~ //注意使用字符串查询条件(不推荐) :SELECT * FROM think_user WHERE type=1 AND status=1 Db::table('think_user')->whereRaw('type=1 AND status=1')->select(); //字符串查询条件预处理 Db::table('think_user') ->whereRaw("id=:id and username=:name", ['id' => 1 , 'name' => 'thinkphp']) ->select(); //SELECT * FROM think_user WHERE `name`='thinkphp' AND id > 1 Db::table('think_user') ->where('id','>',1) ->where('name','thinkphp') ->select(); //等值 and条件 传入数组作为查询条件:SELECT * FROM think_user WHERE `name`='thinkphp' AND status = 1 Db::table('think_user')->where([ 'name' => 'thinkphp', 'status'=> 1 ])->select(); //索引数组条件查询(推荐) // 传入数组作为查询条件 Db::table('think_user')->where([ ['name','=','thinkphp'], ['status','=',1] ])->select(); //数组条件 $map['name'] = 'thinkphp';//普通查询 $map['status'] = 1;//普通查询 $map['id'] = ['>',1];//使用查询表达式 $map['mail'] = ['like','%thinkphp@qq.com%'];//使用查询表达式 Db::table('think_user')->where($map)->select(); ~~~