我想从表用户返回值 dep_id 以使用它,所以 setState 应该像 (Yii::app()->user->depId) 一样返回它但是当我使用它时我得到 - “CWebUser.depId”是没有定义的。我搜索了,我不知道该怎么做,我需要一个快速的答案这是我的例子:
private $_id;
//private $_dep_id;
public function authenticate()
{
    $user=User::model()->find('LOWER(username)=?',array(strtolower($this->username)));
    if($user===null)
        $this->errorCode=self::ERROR_USERNAME_INVALID;
    else if(!$user->validatePassword($this->password))
        $this->errorCode=self::ERROR_PASSWORD_INVALID;
    else
    {
        $this->_id=$user->id;
        $this->setState('depId',$user->dep_id);            
        $this->username=$user->username;
        $this->setState('lastLogin', date("m/d/y g:i A", strtotime($user->last_login_time)));
        $user->saveAttributes(array('last_login_time'=>date("Y-m-d H:i:s", time())));
        $this->errorCode=self::ERROR_NONE;
    }
    return $this->errorCode==self::ERROR_NONE;
}
public function getId()
{
    return $this->_id;
}
然后我得到这个
Property "CWebUser.depId" is not defined.
这里有什么问题 ?!