我编写了以下代码来使用查询构建器构建查询。
$em = $this->_em;
$qb = $em->createQueryBuilder();
$qb->select('tbl');
$qb->addSelect('COUNT(tbl.macId) AS totalInstallations');
$qb->addSelect('COUNT(DISTINCT tbl.macId) AS uniqueInstallations');
$qb->addSelect('COUNT(CASE
WHEN tbl.updatedOn IS NOT NULL THEN tbl.macId ELSE NULL
END) AS totalUninstallations');
$qb->from('Entity\SoftwareInstallation', 'tbl');
$result = $qb->getQuery()->getArrayResult();
return $result;
但是在案件情况下它不起作用。
我收到以下错误:
键入:Doctrine \ ORM \ Query \ QueryException
消息:[语法错误]第0行,第152行:错误:预期 Doctrine \ ORM \ Query \ Lexer :: T_FROM,得到'。'
文件名: /var/www/html/ghostnew/application/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php
行号:52