Skip to content

Commit

Permalink
Fix bug 1717 : SQLite: access failure on Admin > Tools > History
Browse files Browse the repository at this point in the history
hour function doesn't exists

git-svn-id: http://piwigo.org/svn/trunk@6463 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
nikrou committed Jun 4, 2010
1 parent 8a1f11a commit fd0f465
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions admin/stats.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -116,14 +116,17 @@ function get_summary($year = null, $month = null, $day = null)
$query = ' $query = '
SELECT SELECT
date, date,
HOUR(time) AS hour, hour(time) AS hour,
MAX(id) AS max_id, MAX(id) AS max_id,
COUNT(*) AS nb_pages COUNT(*) AS nb_pages
FROM '.HISTORY_TABLE.' FROM '.HISTORY_TABLE.'
WHERE summarized = \'false\' WHERE summarized = \'false\'
GROUP BY GROUP BY
date,
hour
ORDER BY
date ASC, date ASC,
HOUR(time) ASC hour ASC
;'; ;';
$result = pwg_query($query); $result = pwg_query($query);


Expand Down
6 changes: 6 additions & 0 deletions include/dblayer/functions_pdo-sqlite.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function pwg_db_connect($host, $user, $password, $database)
} }


$link->sqliteCreateFunction('now', 'pwg_now', 0); $link->sqliteCreateFunction('now', 'pwg_now', 0);
$link->sqliteCreateFunction('hour', 'pwg_hour', 1);
$link->sqliteCreateFunction('unix_timestamp', 'pwg_unix_timestamp', 0); $link->sqliteCreateFunction('unix_timestamp', 'pwg_unix_timestamp', 0);
$link->sqliteCreateFunction('md5', 'md5', 1); $link->sqliteCreateFunction('md5', 'md5', 1);
$link->sqliteCreateFunction('if', 'pwg_if', 3); $link->sqliteCreateFunction('if', 'pwg_if', 3);
Expand Down Expand Up @@ -570,6 +571,11 @@ function pwg_now()
return date('Y-m-d H:i:s'); return date('Y-m-d H:i:s');
} }


function pwg_hour($datetime)
{
return strftime('%H', $datetime);
}

function pwg_unix_timestamp() function pwg_unix_timestamp()
{ {
return time(); return time();
Expand Down
6 changes: 6 additions & 0 deletions include/dblayer/functions_sqlite.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function pwg_db_connect($host, $user, $password, $database)
} }


$link->createFunction('now', 'pwg_now', 0); $link->createFunction('now', 'pwg_now', 0);
$link->createFunction('hour', 'pwg_hour', 1);
$link->createFunction('unix_timestamp', 'pwg_unix_timestamp', 0); $link->createFunction('unix_timestamp', 'pwg_unix_timestamp', 0);
$link->createFunction('md5', 'md5', 1); $link->createFunction('md5', 'md5', 1);
$link->createFunction('if', 'pwg_if', 3); $link->createFunction('if', 'pwg_if', 3);
Expand Down Expand Up @@ -582,6 +583,11 @@ function pwg_now()
return date('Y-m-d H:i:s'); return date('Y-m-d H:i:s');
} }


function pwg_hour($datetime)
{
return strftime('%H', $datetime);
}

function pwg_unix_timestamp() function pwg_unix_timestamp()
{ {
return time(); return time();
Expand Down

0 comments on commit fd0f465

Please sign in to comment.