Symfony 模式在我的本地服务器上工作,但在转移到 Dreamhost 时出现了foreign_key 约束问题
我正在使用 symfony 1.4 和原则。过去几天我一直在研究我的模式,并且我已经让它正确加载/构建/运行,但仅限于我的本地计算机。当我将文件复制到 Dreamhost 上的帐户时,更改配置以允许连接到该数据库(仅此而已),尝试删除应级联的内容时出现以下错误(当我在本地计算机上删除它时也会出现此错误) :
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent
row: a foreign key constraint fails (`ezshirtdb`.`item_options`, CONSTRAINT
`item_options_item_id_items_id` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`))
这是我的架构:http://pastie.org/1097068
这些是我的固定装置: http://pastie.org/1097072
dreamhost DB 中的表都是 InnoDB,数据库本身好像是MYISAM。这是一个问题吗?在这种情况下,我无法删除项目 #1(它具有关联的 ItemOptions)或任何类别(具有关联的项目)。
我完全迷路了,需要一些指点。谢谢你们。
I'm using symfony 1.4 and doctrine. I've spent the last couple days playing with my schema, and I've gotten it to load up / build / behave properly but only on my local machine. When I copy the files to an account on Dreamhost, change the configuration to allow a connection to that database (and nothing else) I get the following error trying to delete something which should cascade (and does when I delete it on my local machine):
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent
row: a foreign key constraint fails (`ezshirtdb`.`item_options`, CONSTRAINT
`item_options_item_id_items_id` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`))
This is my schema: http://pastie.org/1097068
These are my fixtures: http://pastie.org/1097072
The tables in the dreamhost DB are all InnoDB, the database itself seems to be MYISAM. Is that an issue? In this case, I can't delete Item #1, which has ItemOptions associated onto it, or any of the categories (which have items associated).
I'm totally lost, and could use a couple pointers. Thanks y'all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不久前我遇到了这样的错误,这是由于外键生成后的整数大小不同。
查看数据库,并确保 Items.ID 字段和 ItemOptions.item_id 字段的类型相同。
I got errors like this a while back, and it was due to the foreign key being a different integer size after being generated.
Take a look at the database, and ensure that both the Items.ID field, and the ItemOptions.item_id field are the same type.
删除数据库并重新创建。 MyISAM或InnoDB,是无关紧要的。
Delete the database and create it again. MyISAM or InnoDB, is irrelevant.