将心比心,方得人心~

thinkphp5中怎么查询类似(a=1 and b=2) or (c=5 and d=6)的数据?

周洲 2017-12-15 15:06:34

方法:闭包查询:


    /**
     * 判断当前登录者是否是项目管理员
     * @Author:急速蜗牛 <zhouxiaodong902@163.com> <http://www.baiduyo.com>
     * @param $loginInfo 用户登录信息
     */
    public function jurisdiction($loginInfo) {
        $data = $this
            ->where(function($query) use ($loginInfo) {
                $query->where(array('manager_id'=>$loginInfo['id'],'manager_phone_number'=>$loginInfo['phone_number']));})
            ->whereOr(function($query) use ($loginInfo) {
                $query->where(array('superior_manager_id'=>$loginInfo['id'],'superior_manager_phone_number'=>$loginInfo['phone_number']));})
            ->find();
        if (!$data) {
           return $jurisdiction = 0;    //不是管理员
        }
        return $jurisdiction = 1;  //是管理员
    }


打赏

『微信打赏』

Tag标签thinkphp5 

我是有底线的