0

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.

Community
  • 1
  • 1
zak_mckraken
  • 805
  • 6
  • 9
  • Why do you manually manager your vendor folder and not let composer do it? – Flip Aug 18 '13 at 17:31
  • I didn't use composer since I first installed it along with Doctrine and I forgot it's existence. I deleted the whole thing and started over with doctrine + extensions over composer. Thanks for the reminder. – zak_mckraken Aug 18 '13 at 20:35

1 Answers1

0

It turns out that after modifying correctly my bootstrap.php file, I was still unable to make the function work. After some fiddling, I found out that while my query still doesn't work, the function do work using this form :

$results = $s->select("GroupConcat(t.name) As Name")->from("Type","t")->getQuery()->getResult();

So, after all, my problem resides in the DQL syntax using GroupConcat.

zak_mckraken
  • 805
  • 6
  • 9