登录模块错误:属性“LoginForm._id"没有定义 [英] Login Module Error: Property "LoginForm._id" is not defined
本文介绍了登录模块错误:属性“LoginForm._id"没有定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 Yii 中创建登录模块,但出现意外错误:
I am trying to create a login module in Yii but I am getting an unexpected error:
未定义属性LoginForm._id".
Property "LoginForm._id" is not defined.
我在 UserIdentify 类上使用 $_id
变量.为什么会显示 LoginForm._id not defined 的错误?
I am using an $_id
variable on UserIdentify class. Why it is showing an error that LoginForm._id not defined?
class UserIdentity extends CUserIdentity {
/**
* Authenticates a user.
*/
private $_id;
public function authenticate() {
$user = Users::model()->findByAttributes(array('username' => $this->username));
if ($user === null)
$this->errorCode = self::ERROR_USERNAME_INVALID;
else if ($user->password !== $this->password)
$this->errorCode = self::ERROR_PASSWORD_INVALID;
else {
$this->_id = $user->id;
$this->setState('lastLoginTime', $user->lastLoginTime);
$this->errorCode = self::ERROR_NONE;
}
return !$this->errorCode;
}
public function getId() {
return $this->id;
}
}
推荐答案
你应该修正错字:
/**
* @return integer the ID of the user record
*/
public function getId()
{
return $this->_id;
}
这篇关于登录模块错误:属性“LoginForm._id"没有定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文