gpt4 book ai didi

mysql - symfony 装置 : set ondelete: CASCADE on refclass table

转载 作者:行者123 更新时间:2023-11-29 09:18:42 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com