thinkphp 多个字段的不同关系的查询条件实现 .

tp的$map不同条件默认是 and ,如果要用or<><><><>如下

例如查询Stu表中年龄大于18,或者身高低于180cm的男性(1为男性),(例子不太好标题有可能不符,望见谅)

$where['age'] = array("gt",18);

$where['height'] =array("lt",180);

$where['_logic'] = "OR";

$map["_complex"] = $where;

$map['sex'] = 1;

$res = M("Stu")->where($map)->select();

posted @ 2017-10-26 11:43  天国的恩赐  阅读(2044)  评论(0编辑  收藏  举报