Answer the question
In order to leave comments, you need to log in
How to create an unusual tree on twig symfony2?
Good day friends, the question is, we have tables
The end result looks like this
That is, in theory, we should link these 3 tables for output in this format, I want to emphasize that it is in this format that records should be output as shown in the example. If we select these tables from the database in conjunction with a double join, for example
SELECT Category.id catid, Category.name catname, Model.id modid, Model.name modelname, Model.small_img simg from Category
left join ModelCategory on(ModelCategory.category_id = Category.id)
left join Model on(ModelCategory.model_id = Model.id)
Answer the question
In order to leave comments, you need to log in
Do you use Doctrine ORM? If you want native sql, then look towards named queries and aggregate data into DTOs as you wish. Then give this very DTO with all the data to twig, where you display it as you want. The trick will be that at the named querie level, we will transform the data structure into the one that our application wants to receive. And the rest of the application will not worry about the form in which this good is stored in the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question