【发布时间】:2018-11-20 08:30:44
【问题描述】:
我正在开发一个大型数据库,我在主键和外键之间创建了链接。我正在使用“Apache/2.4.34 (Win32) OpenSSL/1.1.0i PHP/7.2.10”,并且我的代码是使用 PDO 方法构建的。
在我测试删除功能时,我从 errorInfo 中收到了这条消息:
Array (
[0] => 23000
[1] => 1451
[2] => Cannot delete or update a parent row: a foreign key constraint fails (`#DBNAME#`.`#TABLE1-NAME#`, CONSTRAINT `#CONSTRAINT-NAME#` FOREIGN KEY (`user_id`) REFERENCES `#TABLE2-NAME#` (`id`)) ) Cannot delete or update a parent row: a foreign key constraint fails
我知道错误是由于尝试删除具有与其他外键相关的主键的记录而引起的。我想知道的是错误代码编号,当我收到此编号 1451 时,我是否可以始终假设错误位于主键和外键之间,或者它是否也与其他一些错误有关?
我尝试使用错误消息搜索 errorInfo 代码的完整列表,但没有成功。有人可以告诉我这个列表是否存在于互联网上的某个地方。谢谢
【问题讨论】:
标签: php pdo error-handling