Symfony 1.4/doctrine/sfGuard schema.yml 在多对多关系中使用 sfDoctringGuardPlugin 的 sfGuardGroup 表

发布于 2024-11-28 21:22:12 字数 1681 浏览 4 评论 0原文

我正在使用 sfGuardPlugin,尤其是 sfGuardGroup 表,该表与“监视器”表建立多对多关系(多对多表称为 ALERT): 这是我的 schema.yml:

Monitor:
  tableName: monitor
  actAs:
    Timestampable: ~
  columns:
    id : {type: integer(4), primary: true, autoincrement: true}
    label: {type: string(45)}
    url: {type: string(80)}
    frequency: {type: integer}
    timeout: {type: integer}
    method: {type: enum, values: [GET, POST]}
    parameters: {type: string(255)}
    Groups:
      class: Groups
      local: monitor_id
      foreign: groups_id
      refClass: Alert

Groups:
  inheritance:
    extends: sfGuardGroup
    type: simple
  relations:
    Monitor:
      class: Groups
      local: id
      foreign: monitor_id
      refClass: Alert

Alert:
  actAs:
    Timestampable: ~
  columns:
    monitor_id: { type: integer(4), primary: true }
    groups_id: { type: integer, primary: true }
  relations:
    Monitor:
      foreignAlias: GroupMonitors
    sfGuardGroup:
      foreignAlias: GroupMonitors

构建所有东西时我收到此错误:

  SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'sf_guard_g
roup_id' doesn't exist in table. Failing Query: "CREATE TABLE alert (monitor_id
INT, groups_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NUL
L, INDEX sf_guard_group_id_idx (sf_guard_group_id), INDEX id_idx (id), PRIMARY K
EY(monitor_id, groups_id)) ENGINE = INNODB". Failing Query: CREATE TABLE alert (
monitor_id INT, groups_id BIGINT, created_at DATETIME NOT NULL, updated_at DATET
IME NOT NULL, INDEX sf_guard_group_id_idx (sf_guard_group_id), INDEX id_idx (id)
, PRIMARY KEY(monitor_id, groups_id)) ENGINE = INNODB

有什么想法吗?

am using the sfGuardPlugin and especially the sfGuardGroup table that am using in a many-to-many relation with a "monitor" table (the many to many table is called ALERT):
here is my schema.yml:

Monitor:
  tableName: monitor
  actAs:
    Timestampable: ~
  columns:
    id : {type: integer(4), primary: true, autoincrement: true}
    label: {type: string(45)}
    url: {type: string(80)}
    frequency: {type: integer}
    timeout: {type: integer}
    method: {type: enum, values: [GET, POST]}
    parameters: {type: string(255)}
    Groups:
      class: Groups
      local: monitor_id
      foreign: groups_id
      refClass: Alert

Groups:
  inheritance:
    extends: sfGuardGroup
    type: simple
  relations:
    Monitor:
      class: Groups
      local: id
      foreign: monitor_id
      refClass: Alert

Alert:
  actAs:
    Timestampable: ~
  columns:
    monitor_id: { type: integer(4), primary: true }
    groups_id: { type: integer, primary: true }
  relations:
    Monitor:
      foreignAlias: GroupMonitors
    sfGuardGroup:
      foreignAlias: GroupMonitors

when building all the thigs i get this error :

  SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'sf_guard_g
roup_id' doesn't exist in table. Failing Query: "CREATE TABLE alert (monitor_id
INT, groups_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NUL
L, INDEX sf_guard_group_id_idx (sf_guard_group_id), INDEX id_idx (id), PRIMARY K
EY(monitor_id, groups_id)) ENGINE = INNODB". Failing Query: CREATE TABLE alert (
monitor_id INT, groups_id BIGINT, created_at DATETIME NOT NULL, updated_at DATET
IME NOT NULL, INDEX sf_guard_group_id_idx (sf_guard_group_id), INDEX id_idx (id)
, PRIMARY KEY(monitor_id, groups_id)) ENGINE = INNODB

Any ideas out there?

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

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

发布评论

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

评论(1

蓝礼 2024-12-05 21:22:12

在警报模型中 group_id 应为 sf_guard_group_id
或者
或者,您可以使用 local_id 扩展 sfGuardGroup 的关系部分: group_id

Doctrine 尝试猜测多对多表中使用的 id(如果您未指定它们)。

In the Alert model group_id should be sf_guard_group_id
or
alternatively you could expand the relations section of sfGuardGroup with the local_id: group_id

Doctrine tries to guess the id's used in the Many-to-many table (if you don't specify them).

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