开发者

doctrine 2 , deleting row , contraint fails

开发者 https://www.devze.com 2023-04-01 05:43 出处:网络
i tried deleting from a user, inside the users entity, i have a one to manyproperty: /** @OneToMany(targetEntity=\"\\Entities\\comments\", mappedBy=\"comments\", cascade={\"persist\"}) */

i tried deleting from a user , inside the users entity, i have a one to many property:

/** @OneToMany(targetEntity="\Entities\comments", mappedBy="comments", cascade={"persist"}) */
protected $usercomments;

as there are comments, i cannot remove the main user... errors:

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails

i also tried: cascade={"persist", "remove"} , still no joy when deleting...

do i have to delete all comments for this user first in a loop then remove user as i thought it would delete all related 开发者_如何学Cautomatically.


Try * @joinColumn(onDelete="SET NULL", onUpdate="SET NULL")

0

精彩评论

暂无评论...
验证码 换一张
取 消