我想删除与另一个实体的一对一关系相关的实体。但我总是失败。这是我尝试过的代码:
$adminid=$centrex->getDefadmin()->getId();
$defadmin = $em->getRepository('TelnOperatorBundle:Defadmin')->find($adminid);
$em->remove($defadmin);
$em->flush();
有人可以帮助我吗?问题如下:
An exception occurred while executing 'DELETE FROM DefAdmin WHERE id = ?' with params {"1":"5"}:
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`symfony`.`centrex`, CONSTRAINT `FK_63C80A4692343E35` FOREIGN KEY (`defadmin_id`) REFERENCES `defadmin` (`id`))