From 6e7f8d269e3c84807072607edc765d6c0f72712c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 31 Mar 2006 05:19:45 +0100 Subject: [PATCH] remove PG_VERSION config variable, get version from server --- config.php-dist | 3 --- functions.php | 10 +++++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config.php-dist b/config.php-dist index d07f2eb64..fa7376af7 100644 --- a/config.php-dist +++ b/config.php-dist @@ -9,9 +9,6 @@ define('DB_PASS', "XXXXXX"); //define('DB_PORT', '5432'); // when neeeded, PG-only - define('PG_VERSION', '8.0'); - // Your PostgreSQL server version. Valid values: 7.4, 8.0, 8.1 - define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache'); // Local cache directory for RSS feeds diff --git a/functions.php b/functions.php index be95caa04..14d9fa154 100644 --- a/functions.php +++ b/functions.php @@ -24,7 +24,9 @@ (SELECT date_entered FROM ttrss_entries WHERE id = ref_id) < NOW() - INTERVAL '$purge_interval days'"); */ - if (PG_VERSION == "7.4" || PG_VERSION == "8.0") { + $pg_version = get_pgsql_version($link); + + if (preg_match("/^7\./", $pg_version) || preg_match("/^8\.0/", $pg_version)) { $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE ttrss_entries.id = ref_id AND @@ -1490,4 +1492,10 @@ } } + function get_pgsql_version($link) { + $result = db_query($link, "SELECT version() AS version"); + $version = split(" ", db_fetch_result($result, 0, "version")); + return $version[1]; + } + ?>