我想进行如下查询:
$qbFoo = $this->createQueryBuilder('foo');
$qbFoo->where($qbFoo->expr()-eq('foo.field', $value));
$qbProduct = $this->createQueryBuilder('product');
$qbProduct->select(['product'])
->addSelect(sprintf('(%s) as foo', $qbFoo->getDQL()))
->where($qbProduct->expr()->eq('product.id', $prodId));
$result = $qbProduct->getQuery()->getResult();
$ result的值将是:
$result[0][0] = {AppBundle\Entity\Product}
$result[0]['foo'] = 6 (6 is the value of foo.id)
我怎样才能得到$结果:
$result[0][0] = {AppBundle\Entity\Product}
$result[0]['foo'] = {AppBundle\Entity\Foo}