【问题标题】:How to custom FOREIGN KEY message on Doctrine? Api platform如何在 Doctrine 上自定义 FOREIGN KEY 消息? API平台
【发布时间】:2021-04-24 09:14:58
【问题描述】:

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

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`))

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

【问题讨论】:

标签: symfony doctrine api-platform.com


【解决方案1】:

我找到了解决办法

 * @UniqueEntity("request")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-17
    • 2013-02-06
    • 2019-11-30
    • 2020-01-15
    • 2019-12-18
    • 1970-01-01
    • 2019-02-27
    • 1970-01-01
    相关资源
    最近更新 更多