$qb = $this->doctrine->em->createQueryBuilder()
->from('User','u')
->select('count(u.name)')
->where('u.name = :name')
->setParameter('name', $user->getUsername());
当我执行$qb->getQuery()->getResult()
时,我收到此错误:
致命错误:在 /var/www/darkfrog/application/libraries/Doctrine/ORM 中未捕获的异常 'Doctrine\ORM\Query\QueryException' 和消息 'SELECT count(u.name) FROM User u WHERE u.name = :name' /Query/QueryException.php:39堆栈跟踪:
#0
/var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(429): Doctrine\ORM\Query\QueryException::dqlError('SELECT count(u....')
#1
/var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(854): Doctrine\ORM\Query\Parser->semanticalError('Class 'User' is...', Array)
#2
/var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1529):Doctrine\ORM\Query\Parser->AbstractSchemaName()
#3
/var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1426):Doctrine\ORM\Query\Parser->RangeVariableDeclaration()
#4
/var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(1168):Doctrine\ORM\Query\Parser->IdentificationVariableDeclaration()
#5
/var/www/darkfrog/application/libraries/Doctrine/ORM/Query/Parser.php(757):/var/www/darkfrog/application/libraries/Doctrine/ORM/Query/QueryException 中的 Doctrine\ORM\Query\Pars .php 在第 49 行