1
0
mirror of synced 2025-02-03 05:49:25 +03:00

Add Expr::concat support for multiple arguments

This commit is contained in:
Giorgio Premi 2015-04-28 10:30:23 +02:00
parent 1b09bb75b0
commit 16172534bb
3 changed files with 4 additions and 3 deletions

View File

@ -526,13 +526,13 @@ class Expr
* Creates a CONCAT() function expression with the given arguments. * Creates a CONCAT() function expression with the given arguments.
* *
* @param mixed $x First argument to be used in CONCAT() function. * @param mixed $x First argument to be used in CONCAT() function.
* @param mixed $y Second argument to be used in CONCAT() function. * @param mixed $y,... Other arguments to be used in CONCAT() function.
* *
* @return Expr\Func * @return Expr\Func
*/ */
public function concat($x, $y) public function concat($x, $y)
{ {
return new Expr\Func('CONCAT', array($x, $y)); return new Expr\Func('CONCAT', func_get_args());
} }
/** /**

View File

@ -3464,7 +3464,7 @@ class Parser
/** /**
* FunctionsReturningStrings ::= * FunctionsReturningStrings ::=
* "CONCAT" "(" StringPrimary "," StringPrimary ")" | * "CONCAT" "(" StringPrimary "," StringPrimary {"," StringPrimary}* ")" |
* "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | * "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" |
* "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" | * "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" |
* "LOWER" "(" StringPrimary ")" | * "LOWER" "(" StringPrimary ")" |

View File

@ -184,6 +184,7 @@ class ExprTest extends \Doctrine\Tests\OrmTestCase
public function testConcatExpr() public function testConcatExpr()
{ {
$this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.last_name')); $this->assertEquals('CONCAT(u.first_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.last_name'));
$this->assertEquals('CONCAT(u.first_name, u.middle_name, u.last_name)', (string) $this->_expr->concat('u.first_name', 'u.middle_name', 'u.last_name'));
} }
public function testSubstringExpr() public function testSubstringExpr()