symfony - 如何在 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`))
我想通过一条消息“您无法删除它,因为它在其他地方使用过”来阻止删除
解决方案
我找到了解决方案
* @UniqueEntity("request")
推荐阅读
- text - 如何在 vim/neovim 中制作固定宽度的多行表?
- shell - 如何在 Github 上使用“获取内容”API 将文件的内容转储到另一个文件
- azure-cognitive-services - AZURE 认知服务 -> KeyError: 'Endpoint'
- mobile - 无法使用 jmeter 记录移动应用程序步骤
- javascript - 数组中的随机 ID 值
- spring - 如何在 ItemReadListener 中获取步骤名称和步骤执行 ID?
- javascript - 试图执行 PHP 页面的 Ajax 将我带到一个新页面
- neo4j - 将集合的结尾连接到开头
- sudo - 除非以 sudo 启动,否则tigervncserver 会崩溃
- powerapps - 画廊价格列中没有显示价值