summaryrefslogtreecommitdiff
path: root/program/include/rcube_db.inc
diff options
context:
space:
mode:
Diffstat (limited to 'program/include/rcube_db.inc')
-rwxr-xr-xprogram/include/rcube_db.inc32
1 files changed, 27 insertions, 5 deletions
diff --git a/program/include/rcube_db.inc b/program/include/rcube_db.inc
index 5b32798a7..a01b38dd6 100755
--- a/program/include/rcube_db.inc
+++ b/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);