From 799cd9c2f351dc6041f977801977b25d2eb39383 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 10 Apr 2011 19:20:31 +0000 Subject: [PATCH] functions.inc.php: - create_page_browser(): added queries for PgSQL (untested!) git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1033 a1433add-5e2c-0410-b055-b7f2511e0802 --- functions.inc.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/functions.inc.php b/functions.inc.php index 13375384..ae5360ad 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -600,6 +600,9 @@ function create_page_browser($idxfield, $querypart) { # init row counter $initcount = "SET @row=-1"; + if ('pgsql'==$CONF['database_type']) { + $initcount = "CREATE TEMPORARY SEQUENCE rowcount MINVALUE 0"; + } $result = db_query($initcount); # get labels for relevant rows (first and last of each page) @@ -609,6 +612,13 @@ function create_page_browser($idxfield, $querypart) { SELECT $idxfield AS label, @row := @row + 1 AS row $querypart ) idx WHERE MOD(idx.row, $page_size) IN (0,$page_size_zerobase) OR idx.row = $count_results "; + if ('pgsql'==$CONF['database_type']) { + $query = " + SELECT * FROM ( + SELECT $idxfield AS label, nextval('rowcount') AS row $querypart + ) idx WHERE MOD(idx.row, $page_size) IN (0,$page_size_zerobase) OR idx.row = $count_results + "; + } # echo "

$query"; # TODO: $query is MySQL-specific @@ -633,6 +643,10 @@ function create_page_browser($idxfield, $querypart) { } } + if ('pgsql'==$CONF['database_type']) { + db_query ("DROP SEQUENCE rowcount"); + } + return $pagebrowser; }