且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

doctrine2约束违规

更新时间:2022-11-27 11:34:53

如果有人遇到类似的问题,解决方案:

In case someone runs into a similar issue, here is the solution:

/**
 * @var statistic
 *
 * @ORM\OneToOne(targetEntity="statistic", cascade="ALL")
 * @ORM\JoinColumns({
 *   @ORM\JoinColumn(name="fkStatistic", referencedColumnName="pkId", onDelete="SET NULL")
 * })
 */

onDelete 选项将首先删除关系,然后doctrine将执行级联操作。

The onDelete option will remove the relation first and then doctrine will do the cascade operation.