1
0
mirror of synced 2025-01-18 06:21:40 +03:00

Added PostgreSQLs age() and date_part() functions.

This commit is contained in:
lukenukem 2007-08-25 08:06:17 +00:00
parent af14bd3c13
commit d82b58aa10

View File

@ -92,6 +92,34 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression_Driver
* @param string|array(string) strings that will be concatinated.
* @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()
{
$args = func_get_args();