thinkphp5 中 where条件 or,and 同时使用


        $where['is_del'] = 0;
        $whereor['a'] = 1;
        $whereor['b'] = 2;
        $whereor['c'] = 3;
        $whereor['d'] = 4;
        $this->user->where($where)
        ->whereRaw('(id_1 = :a and id_2 = :b) or (id_3= :c and id_4 = :d)',$whereor,'and')
            ->select()->toArray();

        //whereRaw 第一个参数可以自由发挥
        'SELECT * FROM `user` WHERE  `is_del` = 0  AND ( (`id_1` = 1 and `id_2` = 2) or (`id_3` = 3 and `id_4` = 4) )';
 

你可能感兴趣的:(TP,whereOr,whereRaw,or,和,and)