Doctrine query builder allows me to concat two fields only.
class Expr {
// ...
public function concat($x, $y); // Returns Expr\Func
To concatenate 3 fields I use:
$qb->expr()->concat(
'table.field1',
$qb->expr()->concat('table.field2', 'table.field3')
);
And the SQL will be:
CONCAT('table.field1', CONCAT('table.field2', 'table.field3'))
How to get one concat?
When I try to call directly
new Expr\Func('CONCAT', array('table.field1', 'table.field2', 'table.field3'));
Executing query gives me an error
[Syntax Error] line 0, col 237: Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got ','
Dumping DQL:
CONCAT('table.field1', 'table.field2', 'table.field3')
Dumping SQL using $qb->getQuery()->getSQL():
[Syntax Error] line 0, col 237: Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got ','