Symfony、Doctrine、schema.yml、-猜测-关系问题
我准备了一个 schema.yml - 您可以在下面找到 - 。当我构建它时,构建sql并插入sql;我没有遇到任何问题。但是当我尝试加载数据(固定装置)时,它给了我一个错误 - 您可以在下面找到 - 。
我在我的架构上,特别是在我的关系上找不到任何问题。
你有什么想法吗?
非常感谢...
这是我的 schema.yml <代码> www.ermantaylan.com/schema.yml 和错误
: <代码> SQLSTATE[23000]:完整性约束违规:1452 无法添加或更新子行:外键约束失败(tefrika
.articles
,CONSTRAINT articles_issue_id_issues_issue_id
外键 (issue_id
) 参考 issues
(issue_id
) ON DELETE CASCADE)
I prepared a schema.yml -you can find below-. When i build it, build sql and inserting sql; i haven't face any problem. But when i try to load data (fixtures) it gives me an error -you can find below-.
I can't find any problem on my schema and especially on my relationship.
Do you have any ideas?
Thanks a lot in advanced...
Here is my schema.yml
www.ermantaylan.com/schema.yml
And Error:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (tefrika
.articles
, CONSTRAINT articles_issue_id_issues_issue_id
FOREIGN KEY (issue_id
) REFERENCES issues
(issue_id
) ON DELETE CASCADE)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题绝对出在您的装置文件中。
有时,如果您在指定两个主记录之前指定关系记录,您将收到此错误(在您的装置文件中)。
如果您仍然无法识别装置文件中的问题,请将其发布,我可以查看。
编辑:很确定这就是问题所在:
问题尚未创建,因此 ID 不存在。
你们的关系有点奇怪。您有链接到问题的文章,以及链接到文章的问题 - 两者都通过其表中的 ID 字段设置为一对一。这意味着一篇文章属于一个问题,但是,同一问题可能属于另一篇文章?我不确定我能理解它。您可能需要删除其中之一关系。
Your problem is most definitely in your fixtures file.
Sometimes, if you specify the relation record before specifying the two main records, you will get this error (in your fixtures file).
If you still can't identify the problem in your fixtures file, post it, and I can have a look at it.
EDIT: Pretty sure this is the problem:
The issue was not yet created, therefore the ID doesn't exist.
Your relations are a little strange. You have Articles linked to Issues, and Issues linked to Articles -- both set as a one to one via a ID field in their tables. This means an article belongs to a issue, however, that same issue could belong to another article? I'm not sure I can make sense of it. You may need to remove one of the relations.