From 828ca2ba3624d4fb39970a84733dcbb6ab836336 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Sat, 1 Sep 2012 20:37:35 +0200
Subject: [PATCH] translate UNIX_TIMESTAMP() into sqlite and pgsql equivilents

---
 lib/db.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/db.php b/lib/db.php
index 884bbb5e90..1979b82f8c 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -535,8 +535,12 @@ class OC_DB {
 			$query = str_replace( '`', '"', $query );
 			$query = str_replace( 'NOW()', 'datetime(\'now\')', $query );
 			$query = str_replace( 'now()', 'datetime(\'now\')', $query );
+			$query = str_replace( 'UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $query );
+			$query = str_replace( 'unix_timestamp()', 'strftime(\'%s\',\'now\')', $query );
 		}elseif( $type == 'pgsql' ){
 			$query = str_replace( '`', '"', $query );
+			$query = str_replace( 'UNIX_TIMESTAMP()', 'cast(extract(epoch from current_timestamp) as integer)', $query );
+			$query = str_replace( 'unix_timestamp()', 'cast(extract(epoch from current_timestamp) as integer)', $query );
 		}elseif( $type == 'oci'  ){
 			$query = str_replace( '`', '"', $query );
 			$query = str_replace( 'NOW()', 'CURRENT_TIMESTAMP', $query );
-- 
GitLab