我是Yii框架的新手。我在Yii論壇上問過這個問題,但沒有得到任何好的結果,所以我來到了這裏。其實我想在管理員登錄時顯示上次登錄時間。它在Yii用戶模塊中可用。那麼該怎麼做。是否有可能從用戶模塊到索引頁面獲得這些時間?任何幫助和建議都將非常可觀。在Yii框架中獲取最後登錄時間
[更新]
我跟着this link,我犯了這樣的UserIdentity代碼爲每條指令:
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$user=User::model()->findByAttributes(array('username'=>$this->username));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if($user->password!==md5($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;
}
}
現在我要打電話id
和lastlogin
鑑於文件,這樣就可以得到lastlogin time.So我已經在視圖文件中使用了這段代碼。
<?php echo Yii::app()->user->name;?>
<?php echo Yii::app()->user->lastLoginTime;?>
所有更改後,我得到了像錯誤:
Property "CWebUser.lastLoginTime" is not defined.
我在視圖文件中做了它,但它顯示了像這樣的錯誤解析錯誤:語法錯誤,意外的T_VARIABLE。 – NewUser 2011-12-30 08:29:38