G
G
gitdev2019-05-04 05:17:30
symfony
gitdev, 2019-05-04 05:17:30

How to properly add a foreign key in Symfony?

I have a comments relation with post.
For a post, I will be getting comments using the getComments method. You don't need to receive posts to comment.
How to create a relationship so that there is an addition of a foreign key? And where is it better to do it in migration or separately in entity Comments?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-05-04
@Minifets

Use One-To-Many , and it is the bidirectional type of connection. With the correct settings, all necessary foreign keys will be created during the generation of migrations.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question