Musisz utworzyć własną funkcję doktryny użycia GROUP_CONCAT;
config.yml;
orm:
dql:
string_functions:
GROUP_CONCAT: Your\Bundle\DQL\GroupConcat
Twój \ Pakiet \ DQL \ GroupConcat.php;
(źródło: https://github.com/beberlei/DoctrineExtensions/blob/master/src/Query/Mysql/GroupConcat.php)
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
class GroupConcat extends FunctionNode
{
public $isDistinct = false;
public $expression = null;
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return 'GROUP_CONCAT(' .
($this->isDistinct ? 'DISTINCT ' : '') .
$this->expression->dispatch($sqlWalker) .
')';
}
public function parse(\Doctrine\ORM\Query\Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$lexer = $parser->getLexer();
if ($lexer->isNextToken(Lexer::T_DISTINCT)) {
$parser->match(Lexer::T_DISTINCT);
$this->isDistinct = true;
}
$this->expression = $parser->SingleValuedPathExpression();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
}
Następnie w konstruktora zapytań (lub DQL);
$qb->select('GROUP_CONCAT(category.name)');
Doctrine nie wie, czym jest "group_concat", więc musisz uczyć Doktryny, co z nią zrobić. Dokumentacja na http://doctrine-orm.readthedocs.org/en/latest/cookbook/dql-user-defined-functions.html – Koalabaerchen