$qb = $this->doctrine->em->createQueryBuilder()
->from('User','u')
->select('count(u.name)')
->where('u.name = :name')
->setParameter('name', $user->getUsername());
When I execute $qb->getQuery()->getResult()
,
I get this error:
Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT count(u.name) FROM User u WHERE u.name = :name' in /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/QueryException.php:39Stack trace:
#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): Doctrine\ORM\Query\Pars in /var/www/darkfrog/application/libraries/Doctrine/ORM/Query/QueryException.php on line 49