From a1dba20aff8c825daa4cd522ce95028610f0935d Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Mon, 24 Oct 2011 23:32:45 +0000 Subject: [PATCH] model/DomainHandler: - read_from_db(): provide a working $colformat['ts'] for postgresql _and_ mysql (the only mysql/pgsql-specific code in DomainHandler, everything else works with both) git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1242 a1433add-5e2c-0410-b055-b7f2511e0802 --- model/DomainHandler.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/model/DomainHandler.php b/model/DomainHandler.php index d35cf5e2..a0044f12 100644 --- a/model/DomainHandler.php +++ b/model/DomainHandler.php @@ -277,9 +277,16 @@ class DomainHandler extends PFAHandler { $yes = escape_string(Lang::read('YES')); $no = escape_string(Lang::read('NO')); + # TODO: replace hardcoded %Y-%m-%d with a country-specific date format via *.lang? + # TODO: (not too easy because pgsql uses a different formatstring format :-/ ) + if (Config::read('database_type') == 'pgsql') { + $formatted_date = "TO_DATE(text(###KEY###), 'YYYY-mm-dd')"; + } else { + $formatted_date = "DATE_FORMAT(###KEY###, '%Y-%m-%d')"; + } + $colformat = array( - # TODO: replace hardcoded %Y-%m-%d with a country-specific date format via *.lang? - 'ts' => "TO_DATE(text(###KEY###), 'YYYY-mm-dd') AS ###KEY###, ###KEY### AS _###KEY###", + 'ts' => "$formatted_date AS ###KEY###, ###KEY### AS _###KEY###", 'bool' => "CASE ###KEY### WHEN '" . db_get_boolean(true) . "' THEN '1' WHEN '" . db_get_boolean(false) . "' THEN '0' END as ###KEY###," . "CASE ###KEY### WHEN '" . db_get_boolean(true) . "' THEN '$yes' WHEN '" . db_get_boolean(false) . "' THEN '$no' END as _###KEY###", );