我在尝试实现此代码时遇到此错误。具有$ 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