一直说未定义属性,下面将如何定义代码和堆栈跟踪。我正在为此项目使用Yii框架。堆栈跟踪显示我也收到了正确的用户ID。
$users= Users::model()->findByAttributes(array('Email'=>$this->Email));
if($users===null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
echo 'failed here1';
}
else if(!$users->validatePassword($this->Password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
echo 'failed here 2';
}
else {
$this->errorCode = self::ERROR_NONE;
$this->_id = $users->UserID; //this is the error line
}
return !$this->errorCode;
}
public function getId() {
return $this->_id;
}
}
堆栈跟踪
您必须_id
在UserIdentity类中定义属性。(因此在任何功能之外)
class UserIdentity extends CUserIdentity {
private $_id;
// .. any functions etc.
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句