thinkphp5闭包查询类似(a=1 and b=2) or (c=5 and d=6)的数据

2018-02-0306:26:49后端程序开发24,023 views字数 555阅读模式

方法:闭包查询:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/477.html

    /**
     * 判断当前登录者是否是项目管理员
     * @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;  //是管理员
    }
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/bc/477.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/bc/477.html
Comments  2  访客  2
    • 123 0

      你這是5.1的寫法 別誤人子弟好麽,發佈個文章版本都寫不明白。

        • 456 0

          @ 123 確實可以 wdnmd 我道歉 我錯了

      Comment

      匿名网友 填写信息

      :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

      确定