1,多条件模糊查询
等于:map[‘id′]=array(‘eq′,100);不等于:map[‘id′]=array(‘eq′,100);不等于:map[‘id’] = array(‘neq’,100);
大于 :map[‘id′]=array(‘gt′,100);大于等于:map[‘id′]=array(‘gt′,100);大于等于:map[‘id’]=array(‘egt’,100);
小于:map[‘id′]=array(‘lt′,100);小于等于:map[‘id′]=array(‘lt′,100);小于等于:map[‘id’]=array(‘elt’,100);
模糊查询:map[‘name′]=array(‘like′,′thinkphpbetween:map[‘name′]=array(‘like′,′thinkphpbetween:map[‘id’]=array(‘between’,’1,8’);
map[‘id′]=array(‘between′,array(‘1′,‘8′));in:map[‘id′]=array(‘between′,array(‘1′,‘8′));in:map[‘id’]=array(‘id’,’1,2,,3’);
map[‘id′]=array(‘notin′,′1,2,3′);map[‘id′]=array(‘notin′,′1,2,3′);data=db('user')->where($map)->select();
2多条件或查询
例如 select * from tbl where a like ‘%123%’ or b like ‘%123%’ or c like ‘%123%’ ;
实现这样的功能,thinkphp怎么写呢?
where[‘a’]=array(‘like’,”%123%”);
where[‘b’]=array(‘like’,”%123%”);
where[‘c’]=array(‘like’,”%123%”);
答案 :where[‘a|b|c’]=array(‘like’,”%123%”);
3多条件分页查询保留参数
Db::name(“table”)->where(“XXXX”)->paginate(10,false,['query'=>request()->param()]);
paginate方法的第三个参数