- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 symfony 1.4.5、Doctrine 1.2 和 Mysql 5。
在我的 schema.yml 中,我有一些效果很好的多对多关系。但我需要连接表具有 onDelete: CASCADE。
现在,为了 Doctrine ,需要在外键存在的一侧添加 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 被忽略。
有人知道如何让它工作吗?
最佳答案
其实我原来的答案是正确的。以下是我在正在构建的应用程序中执行此操作的方法。
因此 UserSearch 有一个名为 SearchTag 的 m-m 连接表。但我想将 UserSearch 的删除级联到 SearchTag 表。
因此,我明确定义了与 SearchTag 的关系,并将级联置于该关系上。
我不喜欢使用 ondelete,因为这意味着您可以破坏 phpmyadmin 等中的内容,因此使用“cascade: [delete]”意味着所有删除都由应用程序处理。
UserSearch:
actAs: [Timestampable]
columns:
user_id:
type: integer(4)
update_minutes: integer(4)
last_ran: integer
next_run: integer
running: boolean
relations:
Tags:
class: Tag
local: search_id
foreign: tag_id
refClass: SearchTag
SearchTags:
local: id
foreign: search_id
class: SearchTag
type: many
foreignType: one
cascade: [delete]
SearchTag:
columns:
search_id:
type: integer
primary: true
tag_id:
type: integer
primary: true
Tag:
columns:
name: {type: string(255), notnull: true}
relations:
Searches:
class: UserSearch
local: tag_id
foreign: search_id
refClass: SearchTag
SearchTags:
local: id
foreign: tag_id
class: SearchTag
type: many
foreignType: one
cascade: [delete]
关于mysql - symfony 装置 : set ondelete: CASCADE on refclass table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3100674/
我目前正在设计一个网站,使用 symfony (1.2) 和 Doctrine 作为 ORM。 我有一个晚餐类、一个标准类和一个标记类。 标记与晚餐和 标准,并具有私有(private)属性, 如 D
我有以下架构 User: columns: id: type: integer primary: true name: stri
我正在使用 symfony 1.4.5、Doctrine 1.2 和 Mysql 5。 在我的 schema.yml 中,我有一些效果很好的多对多关系。但我需要连接表具有 onDelete: CASC
我是一名优秀的程序员,十分优秀!