Symfony 4问题中的beberlei / DoctrineExtensions GROUP_CONCAT

时间:2019-09-29 12:55:50

标签: php mysql symfony

我遵循了https://github.com/beberlei/DoctrineExtensions所示的步骤 但是当我尝试使用GroupConcat时,它将返回:

Symfony\Component\Debug\Exception\ClassNotFoundException:
Attempted to load class "GroupConcat" from namespace "DoctrineExtensions\Query\Mysql".
Did you forget a "use" statement for another namespace?

  at vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php:3529
  at Doctrine\ORM\Query\Parser->CustomFunctionsReturningStrings()
     (vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php:3402)

doctrine.yaml

doctrine:
    orm:
        dql:
            string_functions:
                group_concat: DoctrineExtensions\Query\Mysql\GroupConcat

Repository.php

$qb = $this->createQueryBuilder('u');
$qb = $qb->select("c.code, c.description, count(u) as total, GROUP_CONCAT(DISTINCT u.id SEPARATOR ', ') AS ids");

我也将其放在顶部:

use DoctrineExtensions\Query\Mysql\GroupConcat;

0 个答案:

没有答案