【发布时间】:2015-09-04 06:21:14
【问题描述】:
我编写了以下代码来使用查询构建器构建查询。
$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
【问题讨论】:
标签: doctrine-orm query-builder