ThinkPHP : Illegal offset type in isset or empty ,环境php7

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37682202/article/details/83817865

最近做权限访问,把php版本升级到7,突然发现本来的Auth.php竟然报错了,一步一步调试之后,发现是写法不兼容,于是改了一下类控制器,代码如下:

//把Auth.php 197行的查询
$user_groups = Db::view($auth_group_access, 'uid,group_id')
            ->view($auth_group, 'title,rules', "{$auth_group_access}.group_id={$auth_group}.id", 'LEFT')
            ->where("{$auth_group_access}.uid='{$uid}' and {$auth_group}.status='1'")
            ->select();

//替换成如下:
$user_groups = db('auth_group_access')->alias('a')->join('auth_group b','a.group_id=b.id', 'LEFT')->field('uid,group_id,title,rules')->where("a.uid='{$uid}' and b.status='1'")
            ->select();

猜你喜欢

转载自blog.csdn.net/qq_37682202/article/details/83817865
今日推荐