Option 1 and Option 2 seem to give similar results. Is there a particular advantage for using the execute statement rather than the usual getResult() method?
Option 1:
public function getEventsByOrganiser(EventInterface $event, $username)
{
$qb = $this->repository->createQueryBuilder('e')
->select(array('e', 'u'))
->leftJoin('e.user', 'u')
->andWhere('u.username = :username');
return $qb->getQuery()->execute(array(
'username' => $username
));
}
Option2:
public function getEventsByOrganiser(EventInterface $event, $username)
{
$qb = $this->repository->createQueryBuilder('e')
->select(array('e', 'u'))
->leftJoin('e.user', 'u')
->andWhere('u.username = :username')
->setParameter('username', $username);
return $qb->getQuery()->getResult();
}