In Doctrine (Symfony3) I am trying to fetch minimal data from my visit record with an array-result:
public function findByNonDeparted($user)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb
->select('v.id,v.status,v.arrivalStatus,v.personId,v.arrivalDate,v.departureDate')
->from('MyAccommodationBundle:Visit', 'v')
->leftJoin('v.accommodationPeriods','ap')
->leftJoin('ap.roomType','r')
->leftJoin('r.stayArea','s');
return $qb->getQuery()->getArrayResult();
}
How exactly do I include "accommodation periods" in the select statement?
I tried various things:
SELECT('v.id, v.status, v.arrivalStatus, v.personId, v.arrivalDate, v.departureDate, ap')
this gives the following error:
Cannot select entity through identification variables without choosing at least one root entity alias.
adding 'v' in the select statement will solve that, but it will return all values of 'v', and not just the ones i specified in the select-statement
So I tried:
SELECT('v.id, v.status, v.arrivalStatus, v.personId, v.arrivalDate, v.departureDate, v.accommodationPeriods')
This gives the following error:
Must be a StateFieldPathExpression.
Then I tried:
SELECT('v.id, v.status, v.arrivalStatus, v.personId, v.arrivalDate, v.departureDate, IDENTITY(v.accommodationPeriods)')
Then a new error comes up:
Must be a SingleValuedAssociationField.