开发者

Symfony, Doctrine, schema.yml, -guessing- relations problem

开发者 https://www.devze.com 2023-02-08 17:22 出处:网络
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 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 DELE开发者_C百科TE CASCADE)


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:

articles:
  article_1:
    article_id: 1
    issue_id: 1   <----  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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号