E
E
Eobard Thawne2019-04-22 12:00:45
symfony
Eobard Thawne, 2019-04-22 12:00:45

How to take data from two tables in Symfony4?

How to take data from 2 or more tables, all tables are linked by id. But how to take data if there is a connection and when it is not?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Nizhny Novgorod, 2019-04-22
@vexgg

1) Using doctrine links at the entity level is not the best practice if we are talking about high-load, because it does not work in the best way. For projects where entries in tables are less than 100k, in general, you can.
2) If you need a query in the language of the doctrine to two tables, then:
In the repository of one table, write a query, where we insert the line

...
->from(Client::class, 'cl')
->where('cl.siteId = c.siteId')
...

Those. there is a request to the main table with alias 'c', we add an additional table with alias 'cl', they are connected by siteId, and then everything is processed in any way. For Joint, the same thing, but instead of from there is join ... with

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question