我正在使用sfGuardPlugin,特别是与“监视器”表(多对多表称为ALERT)的多对多关系中使用的sfGuardGroup表: 这是我的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
有任何想法吗?
答案 0 :(得分:2)
在Alert模型中,group_id应为sf_guard_group_id 要么 或者,您可以使用local_id:group_id
扩展sfGuardGroup的关系部分Doctrine试图猜测多对多表中使用的id(如果你没有指定它们)。