From 151c3dd8f234d3506eef6af1ff62d7185f813784 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 8 Apr 2014 15:27:51 +0200 Subject: [PATCH] add new method getDateExtract() --- SeedDMS_Core/Core/inc.DBAccessPDO.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/SeedDMS_Core/Core/inc.DBAccessPDO.php b/SeedDMS_Core/Core/inc.DBAccessPDO.php index 9f15e6129..166f5e00b 100644 --- a/SeedDMS_Core/Core/inc.DBAccessPDO.php +++ b/SeedDMS_Core/Core/inc.DBAccessPDO.php @@ -432,6 +432,26 @@ class SeedDMS_Core_DatabaseAccess { } return false; } /* }}} */ + + /** + * Return sql statement for extracting the date part from a field + * containing a unix timestamp + * + * @param string $fieldname name of field containing the timestamp + * @return string sql code + */ + function getDateExtract($fieldname) { /* {{{ */ + switch($this->_driver) { + case 'mysql': + return "from_unixtime(`".$fieldname."`, '%Y-%m-%d')"; + break; + case 'sqlite': + return "date(`".$fieldname."`, 'unixepoch')"; + break; + } + return ''; + } /* }}} */ + } ?>