【问题标题】:Symfony 1.4/doctrine/sfGuard schema.yml Using sfDoctringGuardPlugin's sfGuardGroup table in a many to many relationSymfony 1.4/doctrine/sfGuard schema.yml 在多对多关系中使用 sfDoctingGuardPlugin 的 sfGuardGroup 表
【发布时间】:2011-08-08 15:14:22
【问题描述】:

我正在使用 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

在构建所有 thigs 时出现此错误:

  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

有什么想法吗?

【问题讨论】:

    标签: doctrine symfony-1.4 sfguard


    【解决方案1】:

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

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

    【讨论】:

    • @SymFoNyBegginer,您能否分享您的解决方案,以帮助遇到同样问题的任何人。
    猜你喜欢
    • 2011-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多