多条件查询or和and组合查询

$where1['id'] = 1;
$where1['sex'] = 1;

$where2['name'] = tom;
$where2['sex'] = 2;
->where(function ($q) use($where1) {
        $q->where($where1);
    })
->whereOr(function ($q) use($where2) {
        $q->where($where2);
    })
->fetchSql(true)   //打印出sql语句

  ->select();

猜你喜欢

转载自blog.csdn.net/cmj8043719242/article/details/108584874