$map['phone'] = '1111'; $map2 = ['id' => 16, 'realname' => 'wangxinhua']; $map3 = ['nickname' => 'wangxinhua', 'card_status' => '0']; Db::name('user') ->where($map)->where(function ($query) use ($map2, $map3) { $query->whereOr($map2)->whereOr($map3); }) ->select(); halt(Db::name('user')->getLastSql());
SELECT * FROM `cga_user` WHERE `phone` = '1111' AND ( `id` = 16 OR `realname` = 'wangxinhua' OR `nickname` = 'wangxinhua' OR `card_status` = 0 )