如何在 Doctrine2 中执行 MySQL count(*)?
2022-08-31 00:05:20
我有以下 Doctrine2 查询:
$qb = $em->createQueryBuilder()
->select('t.tag_text, COUNT(*) as num_tags')
->from('CompanyWebsiteBundle:Tag2Post', 't2p')
->innerJoin('t2p.tags', 't')
->groupBy('t.tag_text')
;
$tags = $qb->getQuery()->getResult();
运行时,我收到以下错误:
[Semantical Error] line 0, col 21 near '*) as num_tags': Error: '*' is not defined.
如何在 Doctrine2 中执行 MySQL count(*)?