I have simple Entity:
id username guard
"guard" is id of another user from the same Entity. I have to render view with simple table:
username | name of guard ------------------------- John | Bob
I tried to do that by query:
$ur = $this->getDoctrine()->getRepository(User::class)->createQueryBuilder('u') ->leftJoin(User::class, 'u2', \Doctrine\ORM\Query\Expr\Join::WITH, 'u.guard = u2.id') ->getQuery() ->getResult();
but it gives me just id and username, no joined data. I know that entire query should be like:
SELECT * FROM user u0_ LEFT JOIN user u1_ ON (u0_.guard = u1_.id)
but I can't find the way to implement that by QueryBuilder and then to access that in twig template.
Regards
->addSelect('u2')
– kunicmarko20