简体   繁体   中英

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!

You forgot a closing parenthesis in your select statement

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

should be

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM