I have query builder:
$qb = $this->modelsManager->createBuilder();
$qb->addFrom('App\Model\User', 'user');
$qb->columns(['user.*']);
And it works, but I have to avoid lazy loading problem, when I have:
foreach($user->organizations as $organization){
echo $organization->name();
}
It produces about 0,5k db queries when users list is rendering I try to use join:
$qb = $this->modelsManager->createBuilder();
$qb->addFrom('App\Model\User', 'user');
$qb->columns(['user.*']);
$qb->join('App\Model\Organization');
But query is:
FROM `user` AS `user`
INNER JOIN `organization` ON 1
And of course no effect.
Is it possible to get model without many additional queries?