首页 > 解决方案 > 如何在 Doctrine 上自定义 FOREIGN KEY 消息?API平台

问题描述

这可以显示一条消息而不是这个吗?

An exception occurred while executing 'DELETE FROM plan WHERE id = ?' with params [9]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`api`.`request`, CONSTRAINT `FK_3B978F9FE899029B` FOREIGN KEY (`plan_id`) REFERENCES `plan` (`id`))

我想通过一条消息“您无法删除它,因为它在其他地方使用过”来阻止删除

标签: symfonydoctrineapi-platform.com

解决方案


我找到了解决方案

 * @UniqueEntity("request")

推荐阅读