【发布时间】:2010-06-23 10:08:43
【问题描述】:
我正在使用 symfony 1.4.5、Doctrine 1.2 和 Mysql 5。
在我的 schema.yml 中,我有一些非常有效的多对多关系。但我需要加入表有 onDelete: CASCADE。
现在对于学说,需要在外键存在的一侧添加 onDelete: CASCADE 但由于 refclass 在 schema.yml 中没有任何关系,所以我不能。
示例架构:
Organisatie:
connection: doctrine
tableName: organisatie
columns:
org_id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
naam:
type: string(30)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Sc:
class: Sc
refClass: ScRegel
local: org_id
foreign: sc_id
Sc:
connection: doctrine
tableName: sc
columns:
sc_id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
notnull: true
sc_nummer:
type: string(15)
fixed: false
unsigned: false
primary: false
autoincrement: false
notnull: true
type:
type: string(20)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Organisatie:
class: Organisatie
refClass: ScRegel
local: sc_id
foreign: org_id
ScRegel:
connection: doctrine
tableName: sc_regel
columns:
sc_id:
type: integer(4)
primary: true
autoincrement: true
notnull: true
sc_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
autoincrement: false
notnull: true
org_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
现在我尝试在两侧(Sc 和 Organisatie)添加 onDelete: CASCADE,但在这两种情况下它们都被忽略了,建立了关系,但是 onDelete 被忽略了。
有人知道如何让这个工作吗?
【问题讨论】:
-
两个表都使用 InnoDB 存储引擎吗?
-
感谢您的回复,是的 :) 我的整个数据库是使用 InnoDB 设置的,关系工作正常,只有级联的东西没有传输。
-
你能粘贴 SHOW CREATE TABLE sc 的输出吗? ?
-
也适用于 sc_regel 表:pastebin.com/1rhFm6qL 请注意额外的字段,我在示例中将它们省略了,因为它们对问题并不重要
标签: mysql symfony1 doctrine fixtures