0

Inglês It is possible to return an instance of class in Doctrine2?

PDO is very simple

$query->setFetchMode(PDO::FETCH_CLASS, 'model\vo\envio_vo');
user8045
  • 1
  • 1
  • 2
    Possible duplicate of [How to fetch class instead of array in Doctrine 2](http://stackoverflow.com/questions/10482085/how-to-fetch-class-instead-of-array-in-doctrine-2) – Raymond Nijland May 17 '17 at 14:01

1 Answers1

0

This might help you. This will give you ArrayCollection of User objects

$qb = $this->em->createQueryBuilder();
$qb->select('u');
$qb->from('Entity\User', 'u');
$qb->innerJoin('Entity\UserMeta', 'um', 'WITH', 'um.user = u.id');
$qb->where('u.id = :UserId')->setParameter(':UserId', $userId);

return $qb->getQuery()->getResult();

if you want ArrayCollection of User columns, you can change code like

$qb->select('u.*');
Virendra Jadeja
  • 821
  • 1
  • 10
  • 20