From e6c7c3ca9381aa10f7147544cd93f6179d32f359 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 13 Mar 2007 18:53:26 -0400
Subject: [PATCH] Fixed bugs in rcube_db and rcube_imap classes

---
 program/include/rcube_db.inc |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/program/include/rcube_db.inc b/program/include/rcube_db.inc
index a01b38d..f17605a 100755
--- a/program/include/rcube_db.inc
+++ b/program/include/rcube_db.inc
@@ -293,14 +293,16 @@
       {
       case 'pgsql':
         $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;
 
+      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;
                 
       case 'mysql': // This is unfortuneate
@@ -308,7 +310,7 @@
 
       case 'mysqli':
         return mysqli_insert_id($this->db_handle->connection);
-	
+
       case 'sqlite':
         return sqlite_last_insert_rowid($this->db_handle->connection);
 
@@ -358,7 +360,7 @@
    */
   function _fetch_row($result, $mode)
     {
-    if (DB::isError($result))
+    if (!$result || DB::isError($result))
       {
       raise_error(array('code' => 500, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__,
                         'message' => $this->db_link->getMessage()), TRUE, FALSE);

--
Gitblit v1.9.1