aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornikrou <nikrou@piwigo.org>2010-06-22 21:01:05 +0000
committernikrou <nikrou@piwigo.org>2010-06-22 21:01:05 +0000
commit5a677f1151ec726bcc147eee3e0743ca3153125e (patch)
treead121f3eb3bcb70c56d5ca6d7a1aaa407187d0a1
parentf4d4a3dbcf0ef0e56ff120410ac3e8dee03bfa35 (diff)
Bug 1738 fixed : hour function doesn't exists for database other than mysql.
git-svn-id: http://piwigo.org/svn/trunk@6578 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--admin/stats.php2
-rw-r--r--include/dblayer/functions_mysql.inc.php5
-rw-r--r--include/dblayer/functions_pdo-sqlite.inc.php12
-rw-r--r--include/dblayer/functions_pgsql.inc.php5
-rw-r--r--include/dblayer/functions_sqlite.inc.php11
5 files changed, 22 insertions, 13 deletions
diff --git a/admin/stats.php b/admin/stats.php
index 1ce07649a..cab13c744 100644
--- a/admin/stats.php
+++ b/admin/stats.php
@@ -116,7 +116,7 @@ check_status(ACCESS_ADMINISTRATOR);
$query = '
SELECT
date,
- hour(time) AS hour,
+ '.pwg_db_get_hour('time').' AS hour,
MAX(id) AS max_id,
COUNT(*) AS nb_pages
FROM '.HISTORY_TABLE.'
diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php
index 3160e1902..5e0c4dcd4 100644
--- a/include/dblayer/functions_mysql.inc.php
+++ b/include/dblayer/functions_mysql.inc.php
@@ -580,6 +580,11 @@ SELECT '.pwg_db_get_recent_period_expression($period);
return $d;
}
+function pwg_db_get_hour($date)
+{
+ return 'hour('.$date.')';
+}
+
function pwg_db_get_date_YYYYMM($date)
{
return 'DATE_FORMAT('.$date.', \'%Y%m\')';
diff --git a/include/dblayer/functions_pdo-sqlite.inc.php b/include/dblayer/functions_pdo-sqlite.inc.php
index 365083f0c..2f1727e75 100644
--- a/include/dblayer/functions_pdo-sqlite.inc.php
+++ b/include/dblayer/functions_pdo-sqlite.inc.php
@@ -46,7 +46,6 @@ function pwg_db_connect($host, $user, $password, $database)
}
$link->sqliteCreateFunction('now', 'pwg_now', 0);
- $link->sqliteCreateFunction('hour', 'pwg_hour', 1);
$link->sqliteCreateFunction('unix_timestamp', 'pwg_unix_timestamp', 0);
$link->sqliteCreateFunction('md5', 'md5', 1);
$link->sqliteCreateFunction('if', 'pwg_if', 3);
@@ -502,6 +501,12 @@ function pwg_db_get_recent_period($period, $date='CURRENT_DATE')
return $d;
}
+function pwg_db_get_hour($date)
+{
+ return 'strftime(\'%H\', '.$date.')';
+}
+
+
function pwg_db_get_date_YYYYMM($date)
{
return 'strftime(\'%Y%m\','.$date.')';
@@ -571,11 +576,6 @@ function pwg_now()
return date('Y-m-d H:i:s');
}
-function pwg_hour($datetime)
-{
- return strftime('%H', $datetime);
-}
-
function pwg_unix_timestamp()
{
return time();
diff --git a/include/dblayer/functions_pgsql.inc.php b/include/dblayer/functions_pgsql.inc.php
index 6492e82ef..8a300b7ad 100644
--- a/include/dblayer/functions_pgsql.inc.php
+++ b/include/dblayer/functions_pgsql.inc.php
@@ -544,6 +544,11 @@ function pwg_db_get_recent_period($period, $date='CURRENT_DATE')
return $d;
}
+function pwg_db_get_hour($date)
+{
+ return 'EXTRACT(HOUR FROM '.$date.')';
+}
+
function pwg_db_get_date_YYYYMM($date)
{
return 'TO_CHAR('.$date.', \'YYYYMM\')';
diff --git a/include/dblayer/functions_sqlite.inc.php b/include/dblayer/functions_sqlite.inc.php
index 72f539c92..7a33b09a2 100644
--- a/include/dblayer/functions_sqlite.inc.php
+++ b/include/dblayer/functions_sqlite.inc.php
@@ -55,7 +55,6 @@ function pwg_db_connect($host, $user, $password, $database)
}
$link->createFunction('now', 'pwg_now', 0);
- $link->createFunction('hour', 'pwg_hour', 1);
$link->createFunction('unix_timestamp', 'pwg_unix_timestamp', 0);
$link->createFunction('md5', 'md5', 1);
$link->createFunction('if', 'pwg_if', 3);
@@ -514,6 +513,11 @@ function pwg_db_get_recent_period($period, $date='CURRENT_DATE')
return $d;
}
+function pwg_db_get_hour($date)
+{
+ return 'strftime(\'%H\', '.$date.')';
+}
+
function pwg_db_get_date_YYYYMM($date)
{
return 'strftime(\'%Y%m\','.$date.')';
@@ -583,11 +587,6 @@ function pwg_now()
return date('Y-m-d H:i:s');
}
-function pwg_hour($datetime)
-{
- return strftime('%H', $datetime);
-}
-
function pwg_unix_timestamp()
{
return time();