diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2006-08-30 17:41:21 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2006-08-30 17:41:21 +0000 |
| commit | 39697e4e08c3143a6ed066c5b1b13f65765d187f (patch) | |
| tree | 6d3d320f5060d48568081337e140736479c25d2b /roundcubemail/program/include/rcube_db.inc | |
| parent | 1d042c3a6b1ddecbf9e26d08db2d544fdcd09473 (diff) | |
Added MSSQL support
git-svn-id: https://svn.roundcube.net/trunk@328 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/rcube_db.inc')
| -rwxr-xr-x | roundcubemail/program/include/rcube_db.inc | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/roundcubemail/program/include/rcube_db.inc b/roundcubemail/program/include/rcube_db.inc index 5b32798a7..a01b38dd6 100755 --- a/roundcubemail/program/include/rcube_db.inc +++ b/roundcubemail/program/include/rcube_db.inc @@ -292,13 +292,14 @@ class rcube_db switch($this->db_provider) { case 'pgsql': - // PostgreSQL uses sequences $result = &$this->db_handle->getOne("SELECT CURRVAL('$sequence')"); + + case 'mssql': + $result = &$this->db_handle->getOne("SELECT @@IDENTITY"); + if (DB::isError($result)) - { raise_error(array('code' => 500, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__, 'message' => $result->getMessage()), TRUE, FALSE); - } return $result; @@ -421,6 +422,25 @@ class rcube_db } + /* + * Return SQL function for current time and date + * + * @return string SQL function to use in query + * @access public + */ + function now() + { + switch($this->db_provider) + { + case 'mssql': + return "getdate()"; + + default: + return "now()"; + } + } + + /** * Return SQL statement to convert a field value into a unix timestamp * @@ -434,7 +454,9 @@ class rcube_db { case 'pgsql': return "EXTRACT (EPOCH FROM $field)"; - break; + + case 'mssql': + return "datediff(s, '1970-01-01 00:00:00', $field)"; default: return "UNIX_TIMESTAMP($field)"; @@ -456,7 +478,7 @@ class rcube_db case 'mysqli': case 'mysql': case 'sqlite': - return "FROM_UNIXTIME($timestamp)"; + return sprintf("FROM_UNIXTIME(%d)", $timestamp); default: return date("'Y-m-d H:i:s'", $timestamp); |
