最好的方式内连接symfony2

I have a lot of times 2 or more entities who are related to.

For example:

entity avance(): with attributes: id, userId, questionnaireId, questionId

entity questionnaire: id, name, questionsNbres

entity questions: id, question, responseA, responseB, responseC, correctResponse

When I call an avance entity, it is complicated to find the questionnaire name attribut, I have to do a lot of foreach to find the correct one. The same for all the questions that are related to.

I'm sure that a best solution exist, for example with a inner join, but I don't know how to do this in symfony.

You get two tools that responds to theses problems.

You can setup annotations in yours models to automate data fetching. This is the JoinColumn annotation

However, because the JoinColumn usually over-fetching, my recommandation would be to put in place a custom repository, it allow to create complex query with joins.

In your case, I think you need a left join aka "extends my datas, with another data set".