M
M
MasterCopipaster2021-02-19 23:42:03
Doctrine ORM
MasterCopipaster, 2021-02-19 23:42:03

How are entities eager loaded in Doctrine?

Guys tell me, I ran into such a nuisance and I can’t google for 5 symphonies.
I get entity like this

$repository = $this->entity_manager->getRepository(Subscriptions::class);
$subscription = $repository->find(10);
$tariff = $subscription->getTariff();

The bottom line is that when I do getTariff in $tariff is the desired model, but its fields are all null (it’s clear why there is lazy loading), but how can I do eager loading? Just right now, in order for the fields to be loaded, I have to make a crutch
and call any of the getters of this model
$tariff->getCode();
for a separate code?

I tried to google for a long time, but almost all solutions for symfony 2 are outdated already ...

Tell me how to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria Motorina, 2021-02-20
@MasterCopipaster

The doctrine describes that you can specify fetch=eager or fetch=lazy in link mapping, for example, as here
https://www.doctrine-project.org/projects/doctrine...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question