I have an User
, a Question
and an Answer
entity.
- Each
User
has nAnswers
. - Each
Answer
has- an unique
aid
. - a
question
field holding the id of theQuestion
answered. - the actual answer string given by the user, called
answer
.
- an unique
- Each
Question
has 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 :/