使用onDelete与Doctrine 2 [英] using onDelete with Doctrine 2
问题描述
我不能让onDelete在Doctrine2(使用YAML映射)中工作。
我在 Product
class:
oneToOne:
类别:
targetEntity:类别
onDelete:CASCADE
但这不行。
编辑:
我已经在数据库中手动设置了 ON DELETE:CASCADE
p>
使用 doctrine导入YAML映射:mapping:import
,
清空数据库
使用 doctrine:schema:update
从架构更新它,并且没有 ON DELETE
在外键..所以看起来甚至Doctrine不知道该怎么做哈哈..
好的,得到了!我必须在 joinColumn
中使用 onDelete
:
oneToOne:
类别:
targetEntity:类别
joinColumn:
onDelete:CASCADE
I can't get the onDelete to work in Doctrine2 (with YAML Mapping).
I tried this relation in my Product
class:
oneToOne:
category:
targetEntity: Category
onDelete: CASCADE
But that doesn't work..
EDIT:
I've set the ON DELETE: CASCADE
manually in the database
imported the YAML mapping with doctrine:mapping:import
,
emptied the database
updated it from the schema with doctrine:schema:update
and got no ON DELETE
in the foreign key.. so looks like even Doctrine doesn't know how to do it lol..
OK, got it! I had to use onDelete
inside joinColumn
:
oneToOne:
category:
targetEntity: Category
joinColumn:
onDelete: CASCADE
这篇关于使用onDelete与Doctrine 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!