Commit d82b58aa authored by lukenukem's avatar lukenukem

Added PostgreSQLs age() and date_part() functions.

parent af14bd3c
...@@ -92,6 +92,34 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver ...@@ -92,6 +92,34 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver
* @param string|array(string) strings that will be concatinated. * @param string|array(string) strings that will be concatinated.
* @return string * @return string
*/ */
/**
* PostgreSQLs AGE(<timestamp1> [, <timestamp2>]) function.
*
* @param string $timestamp1 timestamp to subtract from NOW()
* @param string $timestamp2 optional; if given: subtract arguments
* @return string
*/
public function age($timestamp1, $timestamp2 = null) {
if( $timestamp2 == null ) {
return 'AGE(' . $timestamp1 . ')';
}
return 'AGE(' . $timestamp1 . ', ' . $timestamp2 . ')';
}
/**
* PostgreSQLs DATE_PART( <text>, <time> ) function.
*
* @param string $text what to extract
* @param string $time timestamp or interval to extract from
* @return string
*/
public function date_part($text, $time) {
return 'DATE_PART(' . $text . ', ' . $time . ')';
}
public function concat() public function concat()
{ {
$args = func_get_args(); $args = func_get_args();
......
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