我在嘗試實現此代碼時遇到此錯誤。具有$ user的第一個代碼塊在數據庫更新時似乎工作,但第二部分失敗。這是錯誤:symfony sfGuard未知記錄屬性/相關組件「sf_guard_user」on「sfGuardUserProfile」
未知記錄屬性/相關組件「sfGuardUserProfile」「sf_guard_user」
public function executeCreateAccount()
{
$user = new sfGuardUser();
$user->setUsername($this->getRequestParameter('username'));
$user->setPassword($this->getRequestParameter('password'));
$user->setIsActive(false);
$user->save();
$profile = new sfGuardUserProfile();
$profile->setsfGuardUser($user);
$profile->setEmail($this->getRequestParameter('user_email'));
$profile->setRemember($this->getRequestParameter('remember', true));
$profile->save();
$this->getRequest()->setAttribute('user', $user);
$raw_email = $this->sendEmail('user', 'registrationConfirmation');
$this->logMessage($raw_email, 'debug');
$this->setFlash('user_email', $this->getRequestParameter('user_email'));
$this->redirect('user/askConfirmation');
}
這裏是我的用戶配置文件的schema.yml:
sf_guard_user_profile:
columns:
id: { type: integer, primary: true, autoincrement: true }
user_id: { type: integer }
firstname: { type: string(255) }
lastname: { type: string(255) }
user_email: { type: string(255) }
relations:
sfGuardUser:
type: one
foreignType: one
class: sfGuardUser
local: user_id
foreign: id
onDelete: cascade
foreignAlias: Profile
我改變,但仍然得到了同樣的錯誤:在「sfGuardUserProfile」 $配置=新sfGuardUserProfile()未知記錄屬性/相關組件「sf_guard_user」; $ profile-> setSfGuardUser($ user); $ profile-> setUserEmail($ this-> getRequestParameter('user_email')); $ profile-> save(); – 2010-09-08 13:15:57