Property" UserIdentity._id"没有定义

时间:2014-08-04 09:43:27

标签: php yii

继续说明属性未定义如何定义代码和堆栈跟踪如下。我正在为这个项目使用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;
    }

}

堆栈跟踪

0

  • C:\ xampp \ htdocs \ barbadosv2 \ protected \ components \ UserIdentity.php(48):CComponent-> __ set(" _id"," 51")

1 个答案:

答案 0 :(得分:2)

您必须在UserIdentity类中定义_id属性。 (所以在任何职能之外)

class UserIdentity extends CUserIdentity {
    private $_id;

     // .. any functions etc.
}