sfDoctrineGuardPlugin 与 sfDoctrineApplyPlugin 的关系(删除和创建用户)

发布于 2024-11-09 04:15:01 字数 1384 浏览 0 评论 0原文

我使用 symfony 1.4.11。我使用 sfDoctrineGuardPlugin 和 sfDoctrineApplyPlugin。所有工作正常,但是...在我的后端我有用户列表,我可以在其中管理用户。当我从后端创建新用户时,他的个人资料仅在 sf_guard_user 表中创建,或者当我从后端删除用户时,它仅从 sf_guard_user 表 中删除他的个人资料,但不会从 sf_guard_user_profile 表 中删除他的个人资料...那么如何修复是吗?也许我在两个插件的配置中都出了问题?谢谢你!

sfGuardUserProfile:
  connection: doctrine
  tableName: sf_guard_user_profile
  columns:
    id:            { type: integer(4), primary: true, autoincrement: true }
    user_id:       { type: integer(4), notnull: true , primary: false }
    salutation:    { type: string(10), notnull: true }
    first_name:    { type: string(30), notnull: true }
    last_name:     { type: string(30), notnull: true }
    country:       { type: string(255), notnull: true }
    postcode:      { type: string(10) , notnull: true }
    city:          { type: string(255), notnull: true }
    address:       { type: string()   , notnull: true }
    phone:         { type: string(50) }
    email:         { type: string(255), notnull: true }
    validate:      { type: string(17) }
    banned:        { type: boolean, default: 0 }
    payed_until:   { type: datetime, notnull: true}
  relations:
    User:
      class: sfGuardUser
      foreign: id
      local: user_id
      type: one
      onDelete: cascade
      foreignType: one
      foreignAlias: Profile

I use symfony 1.4.11. I use sfDoctrineGuardPlugin and sfDoctrineApplyPlugin.All works fine, but... In my backend I have user list, where I can manage users.When I create new user from backend, his profile create only in sf_guard_user table, or when I delete user from backend , it deleted his profile only from sf_guard_user table, , but it do not delete his profile from sf_guard_user_profile table...So how to fix it?Maybe I am made something wrong in cofiguration of both plugins? Thank you!

sfGuardUserProfile:
  connection: doctrine
  tableName: sf_guard_user_profile
  columns:
    id:            { type: integer(4), primary: true, autoincrement: true }
    user_id:       { type: integer(4), notnull: true , primary: false }
    salutation:    { type: string(10), notnull: true }
    first_name:    { type: string(30), notnull: true }
    last_name:     { type: string(30), notnull: true }
    country:       { type: string(255), notnull: true }
    postcode:      { type: string(10) , notnull: true }
    city:          { type: string(255), notnull: true }
    address:       { type: string()   , notnull: true }
    phone:         { type: string(50) }
    email:         { type: string(255), notnull: true }
    validate:      { type: string(17) }
    banned:        { type: boolean, default: 0 }
    payed_until:   { type: datetime, notnull: true}
  relations:
    User:
      class: sfGuardUser
      foreign: id
      local: user_id
      type: one
      onDelete: cascade
      foreignType: one
      foreignAlias: Profile

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朦胧时间 2024-11-16 04:15:01

只需将我的数据库从 MyISAM 更改为 INNODB 即可,一切正常!

Just change my database from MyISAM to INNODB and all works fine!

为你拒绝所有暧昧 2024-11-16 04:15:01

关于创建新用户 - 我不确定这两个插件是否都有这样的功能。 (至少我不知道)。

关于从 sf_guard_user_profile 表中删除用户和相关数据 - 我认为关系定义很可能存在一些问题。再次检查定义 sf_guard_user_profile 表的安装部分中的 sfDoctrineApplyPlugin 自述文件。您需要为用户关系设置onDelete:cascade

最后检查是否生成了正确的 sql 并将其应用于数据库模式。

问候。

About creating new user - I'm not sure if there is such a feature in both plugins in the first place. (At least I don't know about it).

About deleting user and related data from sf_guard_user_profile table - I think that most likely there is some problem with relations definition. Check the sfDoctrineApplyPlugin readme again in the installation section where the sf_guard_user_profile table is defined. You need to have onDelete: cascade set for the User relation.

And at the end check if the proper sql was generated and applied to the database schema.

Regards.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文