我对 Symfony 很陌生,我想知道如何继续将列与字符串进行比较。
我在存储库中使用 QueryBuilder。MySQL 中等效的 WHERE 子句是:
WHERE UPPER(a.name) = UPPER(my_app_var)
class ApplicationRepository extends EntityRepository
{
public function existsByName($name, $caseSensitive = false)
{
$builder = $this->createQueryBuilder('a');
if ($caseSensitive)
{
$builder->where($builder->expr()->eq('a.name', $name));
}
else
{
$builder->where($builder->expr()->eq('a.name', $builder->expr()->upper($name)));
}
return count($builder->getQuery()->getResult()) != 0;
}
}
Symfony 返回一个语法错误:
查询异常:
SELECT a FROM Application a WHERE a.name = UPPER(my_var_app)