As a follow up question to doctrine2 and group_concat, I've been trying to add the GroupConcat user defined function from beberlei to my project, without success. I tried using the offical procedure, but I'm using Doctrine 2 with annotation references so I don't have a config.yaml file. I stumbled into this procedure, which seems simple enough, but the function is still not recognized when I try to use it in a DQL query. Here's the error :
Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 49: Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression, got 'GroupConcat' in C:\xampp\htdocs\MTG\vendor\doctrine\orm\lib\Doctrine\ORM\Query\QueryException.php on line 44
UPDATE :
I realise that the procedure can be very different from one setup to another. In my case, since I first installed Doctrine using the tutorial, I have to put that stuff in my bootstrap.php
file. Here's what I did so far:
1) Install DoctrineExtensions using composer.
2) Add the following to my bootstrap.php file to load the classes :
Doctrine\Common\ClassLoader
$classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', realpath(__DIR__.'/vendor/beberlei/DoctrineExtensions/lib'));
$classLoader->register();
3) Change my bootstrap.php file to define the function :
$config->addCustomStringFunction('GroupConcat', 'DoctrineExtensions\Query\MySql\GroupConcat');
Unfortunately, it still doesn't work. I'm trying to find out if the class actually loads.