src/thinkextend/Auth.php
public function getGroups($uid)
    {
        static $groups = array();
        if (isset($groups[$uid]))
            return $groups[$uid];

        $user_groups = \think\Db::name($this->_config['AUTH_GROUP_ACCESS'] . ' a')
            ->where("a.uid='$uid' and g.status='1'")
            ->join($this->_config['AUTH_GROUP'] . ' g' , "a.group_id=g.id")
            ->field('rules')->select();

        $groups[$uid] = $user_groups ?: array();
        return $groups[$uid];
    }
public function getGroups($uid)
    {
        static $groups = array();
        if (isset($groups[$uid]))
            return $groups[$uid];

        $user_groups = \think\Db::name($this->_config['AUTH_GROUP_ACCESS'] . ' a')
            ->where("a.uid='$uid' and g.status='1'")
            ->join($this->_config['AUTH_GROUP'] . ' g' , "a.group_id=g.id")
            ->field('rules')->select();

        $groups[$uid] = $user_groups ?: array();
        return $groups[$uid];
    }
public function getGroups ( $ uid ) { static $ groups = array ( ) ; if ( isset ( $ groups [ $ uid ] ) ) return $ groups [ $ uid ] ; $ user_groups = \ think \ Db :: name ( $ this -> _config [ 'AUTH_GROUP_ACCESS' ] . ' a' ) -> where ( "a.uid='$uid' and g.status='1'" ) -> join ( $ this -> _config [ 'AUTH_GROUP' ] . ' g' , "a.group_id=g.id" ) -> field ( 'rules' ) -> select ( ) ; $ groups [ $ uid ] = $ user_groups ? : array ( ) ; return $ groups [ $ uid ] ; }
根据用户id获取用户组,返回值为数组
@param  uid int     用户id
@return array       用户所属的用户组 array(
array('uid'=>'用户id','group_id'=>'用户组id','title'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
...)
根据用户id获取用户组 返回值为数组