具有外键约束的 Magento 模型
我正在尝试在我的模块中创建一个模型,用于保存数据并链接到 customer_entity 表。我已经让模块在没有外键约束的情况下保存模型,但是一旦我更改表以包含约束,即使我包含 customer_entity 表中存在的客户 ID,我也会收到完整性约束违规异常。
我需要对模型类或模型资源类做一些额外的事情才能正确保存模型吗?
I am trying to create a model in my module that saves data and links against the customer_entity table. I have got the module saving the model without the foreign key constraint but as soon as I alter the table to include the constraint I get an integrity constraint violation exception even though I am including a customer id that exists in the customer_entity table.
Is there something extra I need to do with my model class or model resource class to get the model saving correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有太多的事情可以成为缓解因素。在某些时候,Magento 正在运行一些临时(或可能永久)导致外键约束的 SQL 查询集。解决这个问题的唯一方法是下拉到模型层下方,查看针对数据库运行的实际 SQL。
There's too many things that could be a mitigating factor here. At some point Magento is running some set of SQL queries that temporarily (or possibly permanently) cause a foreign key constraint. The only way to solve this is to drop down below the Model layer and look at the actual SQL being run against your database.