将 onDelete 与原则 2 一起使用
我无法让 onDelete 在 Doctrine2 中工作(使用 YAML 映射)。
我在我的 Product
类中尝试了这种关系:
oneToOne:
category:
targetEntity: Category
onDelete: CASCADE
但这不起作用..
编辑:
的数据库中手动设置 ON DELETE: CASCADE
我已在导入 YAML 映射 使用doctrine:mapping:import
,
清空数据库,
使用doctrine:schema:update
从架构中更新它,并且在外部没有ON DELETE
关键..看起来如此就像甚至 Doctrine 都不知道该怎么做,哈哈..
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..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,明白了!我必须在
joinColumn
内使用onDelete
:OK, got it! I had to use
onDelete
insidejoinColumn
:这是
joinTable
中使用onDelete
的方法:This is the way to use
onDelete
injoinTable
: