DQL Concat许多字符串

时间:2018-09-06 07:46:13

标签: php symfony doctrine query-builder dql

我想用DQL连接许多字符串,但是尝试时出现错误消息。

我的代码:

  <PropertyGroup>
    <TargetFrameworkMonikerAssemblyAttributesPath>$([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))</TargetFrameworkMonikerAssemblyAttributesPath>
  </PropertyGroup>

错误消息:

$qb = $this->_em->createQueryBuilder();
$qb->select('u')
   ->from(Tutore::class, 'u')
   ->andWhere($qb->expr()->concat($qb->expr()->concat('u.nom', $qb->expr()->literal(' ')), 'u.prenom'), ':fullname')
   ->andWhere($qb->expr()->eq('u.ancien', 0))
   ->setParameter('fullname', $fullname);

return $qb->getQuery()->getOneOrNullResult();

我也尝试通过替换它:

Uncaught PHP Exception Doctrine\ORM\Query\QueryException: "[Syntax Error] line 0, col 77: Error: Expected =, <, <=, <>, >, >=, !=, got 'AND'" at /vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 54

通过简单的“:”。

1 个答案:

答案 0 :(得分:0)

非常简单:

->andWhere("concat(u.nom, ' ', u.prenom) = :fullname")
.............................................................................
相关问题