我需要:
select *, 0 as count from abc;
在doctrine查询构建器中。我正在使用Symfony2
$qb = $this->getEntityManager()->createQueryBuilder();
$r = $qb->select('s, 0 as count')
->from('Wenweipo\SmileysBundle\Entity\Smileys', 's')
->innerJoin('s.group', 'g')
->where('g.id = :group_id')
->setParameter('group_id', $group_id)
->getQuery()
->execute();
但上述查询不起作用。
答案 0 :(得分:1)
正如@meze评论我更新了字段名称并且工作正常。
$r = $qb->select('s,0 as aaaa')
->from('Wenweipo\SmileysBundle\Entity\Smileys', 's')
->innerJoin('s.group', 'g')
->where('g.id = :group_id')
->setParameter('group_id', $group_id)
->getQuery()
->getResult();