I am building a complex SQL query with Doctrine in SYmfony, which involves joining into multiple tables.
As part of the above SQL query, I need to use GROUP_CONCAT and hopefully I bumped on this available extension: https://github.com/beberlei/DoctrineExtensions/blob/master/lib/DoctrineExtensions/Query/Mysql/GroupConcat.php, which I put in under MyBundle\Resources\DoctrineExtensions and I also registered that in my config.yml, such as:
doctrine:
####
orm:
###
entity_managers:
default:
dql:
string_functions:
GROUP_CONCAT: MyBundle\Resources\DoctrineExtensions\GroupConcat
In my class, as I initialize the extension with the following way:
$parameterRepo = $this->em->getRepository('MyBundle:Parameter');
$classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', "MyBundle/Resources/DoctrineExtensions");
$classLoader->register();
$config = new \Doctrine\ORM\Configuration();
$config->addCustomStringFunction('GROUP_CONCAT', 'MyBundle/Resources/DoctrineExtensions');
However, when I am running this query:
$qb->select("
l.identifier,
ct.fooName,
ct.fooShortname,
GROUP_CONCAT(p.field, ':', cp.parameterValue) as params,
ct.section,
p.field
")
->innerJoin('####')
->innerJoin('###')
->leftJoin('###')
->groupBy('###);
I am getting the following error:
[Syntax Error] line 0, col 167: Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got ','
Is this a bug of the extension or I am missing something? How could I proceed with that? Thank you.