我在登录团队应用程序时遇到了一些问题。这是代码.. EWebUser.php
<?php
class EWebUser extends CWebUser{
protected $_model;
protected function loadUser()
{
if ( $this->_model === null ) {
$this->_model = StaffDb::model()->findByPk($this->id);
}
return $this->_model;
}
function getLevel()
{
$user=$this->loadUser();
if ($user->kdstpeg == 02){
if(substr($user->kdorg,1,4) == '0000') $level=1;
else if (substr($user->kdorg,2,3) == '000') $level=2;
return $level;
}
return 100;
}
用户身份.php
<?php
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$username = strtolower($this->username);
$user = MUser::model()->find('LOWER(username)=?', array($username));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if ($user->pwd!=$this->password)
$this->errorCode = self::ERROR_PASSWORD_INVALID;
else
{
$this->_id = $user->oldStaffCode;
$this->username = $user->username;
$this->errorCode = self::ERROR_NONE;
}
return $this->errorCode == self::ERROR_NONE;
}
public function getId()
{
return $this->_id;
}
}
和 StaffDb.php(我的模型之一)
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function tableName()
{
return 'staffdb';
}
public function rules()
{
return array(
array('oldStaffCode', 'required'),
... array('kdstpeg', 'max'=>2),
array('...', 'safe'),
array('oldStaffCode, kdstpeg, ...', 'safe', 'on'=>'search'),
);
}
public function primaryKey()
{
return 'oldStaffCode';
}
当我尝试访问此应用程序时,会显示错误“尝试获取非对象的属性”。然后,我将这段代码放在 EWebUser.phpprint_r ($user);
上,以查看 $user 的视图是什么样的。但它没有任何效果。:(我的问题是,我是否遗漏了代码中的某些内容?因为在我看来,所有对象都是完整的。我希望有解决这个问题的建议。提前致谢。:D