Search code examples
phpsymfonyrequestdql

Symfony 3 - I can't use lower in DQL function


I've a function and i would like put my attributes to lower :

public function getHomonymes($nom, $prenom)
{
    $queryBuilder = $this->createQueryBuilder("u")
    ->select("count(u.id")
    ->where("lower(u.nom) = :nom")
    ->andWhere("lower(u.prenom) = :prenom")
    ->setParameter("nom",strtolower($nom))
    ->setParameter("prenom",strtolower($prenom));
    return $queryBuilder->getQuery()->getSingleScalarResult();
}

But it doesn't work. I get:

[Syntax Error] line 0, col 52: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got 'u'

Thanks for your help!


Solution

  • You forgot a closing parenthesis in your select statement

    ->select("count(u.id")
    

    should be

    ->select("count(u.id)")