Commit 6f5cf403 authored by lsmith's avatar lsmith

- default to sql standard concat syntax instead of mysql's non standard variant

parent 442fb477
...@@ -299,15 +299,16 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module ...@@ -299,15 +299,16 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module
* Returns a series of strings concatinated * Returns a series of strings concatinated
* *
* concat() accepts an arbitrary number of parameters. Each parameter * concat() accepts an arbitrary number of parameters. Each parameter
* must contain an expression or an array with expressions. * must contain an expression
* *
* @param string|array(string) strings that will be concatinated. * @param string $arg1, $arg2 ... $argN strings that will be concatinated.
* @return string
*/ */
public function concat() public function concat()
{ {
$args = func_get_args(); $args = func_get_args();
return 'CONCAT(' . join(', ', (array) $args) . ')'; return join(' || ' , $args);
} }
/** /**
...@@ -717,7 +718,7 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module ...@@ -717,7 +718,7 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module
/** /**
* sin * sin
* *
* @param string $value * @param string $value
* @return void * @return void
*/ */
public function sin($value) public function sin($value)
...@@ -738,7 +739,7 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module ...@@ -738,7 +739,7 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module
/** /**
* cos * cos
* *
* @param string $value * @param string $value
* @return void * @return void
* @author Jonathan H. Wage * @author Jonathan H. Wage
*/ */
...@@ -752,11 +753,11 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module ...@@ -752,11 +753,11 @@ class Doctrine_Expression_Driver extends Doctrine_Connection_Module
* *
* for all native RDBMS functions the function name itself is returned * for all native RDBMS functions the function name itself is returned
*/ */
public function __call($m, $a) public function __call($m, $a)
{ {
if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EXPR) { if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_EXPR) {
throw new Doctrine_Expression_Exception('Unknown expression ' . $m); throw new Doctrine_Expression_Exception('Unknown expression ' . $m);
} }
return $m . '(' . implode(', ', $a) . ')'; return $m . '(' . implode(', ', $a) . ')';
} }
} }
\ No newline at end of file
...@@ -112,16 +112,17 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression_Driver ...@@ -112,16 +112,17 @@ class Doctrine_Expression_Mysql extends Doctrine_Expression_Driver
} }
/** /**
* Returns string to concatenate two or more string parameters * Returns a series of strings concatinated
* *
* @param string $value1 * concat() accepts an arbitrary number of parameters. Each parameter
* @param string $value2 * must contain an expression or an array with expressions.
* @param string $values... *
* @return string to concatenate two strings * @param string|array(string) strings that will be concatinated.
**/ */
function concat($value1, $value2) public function concat()
{ {
$args = func_get_args(); $args = func_get_args();
return 'CONCAT('.implode(', ', $args).')';
return 'CONCAT(' . join(', ', (array) $args) . ')';
} }
} }
...@@ -32,22 +32,6 @@ Doctrine::autoload('Doctrine_Expression_Driver'); ...@@ -32,22 +32,6 @@ Doctrine::autoload('Doctrine_Expression_Driver');
*/ */
class Doctrine_Expression_Oracle extends Doctrine_Expression_Driver class Doctrine_Expression_Oracle extends Doctrine_Expression_Driver
{ {
/**
* Returns a series of strings concatinated
*
* concat() accepts an arbitrary number of parameters. Each parameter
* must contain an expression
*
* @param string $arg1, $arg2 ... $argN strings that will be concatinated.
* @return string
*/
public function concat()
{
$args = func_get_args();
return join(' || ' , $args);
}
/** /**
* return string to call a function to get a substring inside an SQL statement * return string to call a function to get a substring inside an SQL statement
* *
...@@ -105,4 +89,4 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression_Driver ...@@ -105,4 +89,4 @@ class Doctrine_Expression_Oracle extends Doctrine_Expression_Driver
{ {
return 'SYS_GUID()'; return 'SYS_GUID()';
} }
} }
\ No newline at end of file
...@@ -83,17 +83,6 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver ...@@ -83,17 +83,6 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver
} }
} }
/**
* Returns a series of strings concatinated
*
* concat() accepts an arbitrary number of parameters. Each parameter
* must contain an expression or an array with expressions.
*
* @param string|array(string) strings that will be concatinated.
* @return string
*/
/** /**
* PostgreSQLs AGE(<timestamp1> [, <timestamp2>]) function. * PostgreSQLs AGE(<timestamp1> [, <timestamp2>]) function.
* *
...@@ -131,19 +120,6 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver ...@@ -131,19 +120,6 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver
return 'TO_CHAR(' . $time . ', ' . $text . ')'; return 'TO_CHAR(' . $time . ', ' . $text . ')';
} }
/**
* PostgreSQLs CONCAT() function
*
* @param an array of values
* @return string
*/
public function concat()
{
$args = func_get_args();
return join(' || ' , $args);
}
/** /**
* Returns the SQL string to return the current system date and time. * Returns the SQL string to return the current system date and time.
* *
...@@ -223,4 +199,4 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver ...@@ -223,4 +199,4 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver
$match.= $this->patternEscapeString(); $match.= $this->patternEscapeString();
return $match; return $match;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment