Symfony 1.4/doctrine/sfGuard schema.yml 在多对多关系中使用 sfDoctringGuardPlugin 的 sfGuardGroup 表
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在警报模型中 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).