【发布时间】:2022-01-24 00:36:32
【问题描述】:
我用教义查询构建器创建了这个查询,我得到的返回是一个数组数组。 我想得到一个对象数组的返回值,这可能吗?
我知道通常 Doctrine 返回一个实体的对象,有点因为我有一个内部连接来从另一个返回数组的表中获取名称。
提前致谢。
$qb->select('u', 'h.name')
->from('AppBundle:UserHose', 'u')
->innerJoin('AppBundle:Hose', 'h', 'WITH', 'u.hoseId = h.id')
->where('u.userId = :userId')
->orderBy('u.id', 'DESC')
->setParameter('userId', $userId);
return $qb->getQuery()->getResult();
【问题讨论】:
标签: php symfony object doctrine-orm query-builder