I have an User, a Question and an Answer entity.
- Each
Userhas nAnswers. - Each
Answerhas- an unique
aid. - a
questionfield holding the id of theQuestionanswered. - the actual answer string given by the user, called
answer.
- an unique
- Each
Questionhas a uniqueqid.
I want to select all Users ordered by their answer to a specific question. That's how far I got:
$qid = 123; // The id of the question to order the users by.
$orderByDir = 'ASC';
$qb->select('u')
->from('EventManager_Entity_User', 'u')
->leftJoin('u.answers', 'a', \Doctrine\ORM\Query\Expr\Join::WITH, 'a.question = ' . $qid)
->orderBy('a.answer', $orderByDir);
$users = $qb->getQuery()->execute();
But the result isn't ordered :/