开发者

doctrine 2 , deleting row , contraint fails

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜