[Svn] r4670 - trunk/roundcubemail/program/include

trac at roundcube.net trac at roundcube.net
Tue Apr 19 23:00:34 CEST 2011


Author: thomasb
Date: 2011-04-19 16:00:34 -0500 (Tue, 19 Apr 2011)
New Revision: 4670

Modified:
   trunk/roundcubemail/program/include/rcube_mdb2.php
Log:
Check for DB connection state instead of handle (handle could be an error object)

Modified: trunk/roundcubemail/program/include/rcube_mdb2.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_mdb2.php	2011-04-19 20:42:38 UTC (rev 4669)
+++ trunk/roundcubemail/program/include/rcube_mdb2.php	2011-04-19 21:00:34 UTC (rev 4670)
@@ -30,7 +30,7 @@
  * @author     David Saez Padros <david at ols.es>
  * @author     Thomas Bruederli <roundcube at gmail.com>
  * @author     Lukas Kahwe Smith <smith at pooteeweet.org>
- * @version    1.17
+ * @version    1.18
  * @link       http://pear.php.net/package/MDB2
  */
 class rcube_mdb2
@@ -142,7 +142,9 @@
 
         $this->db_handle = $this->dsn_connect($dsn);
         $this->db_connected = !PEAR::isError($this->db_handle);
-        $this->db_mode = $mode;
+
+        if ($this->db_connected)
+          $this->db_mode = $mode;
     }
 
 
@@ -291,7 +293,7 @@
      */
     function num_rows($res_id=null)
     {
-        if (!$this->db_handle)
+        if (!$this->db_connected)
             return false;
 
         if ($result = $this->_get_result($res_id))
@@ -310,7 +312,7 @@
      */
     function affected_rows($res_id = null)
     {
-        if (!$this->db_handle)
+        if (!$this->db_connected)
             return false;
 
         return (int) $this->_get_result($res_id);
@@ -327,7 +329,7 @@
      */
     function insert_id($table = '')
     {
-        if (!$this->db_handle || $this->db_mode == 'r')
+        if (!$this->db_connected || $this->db_mode == 'r')
             return false;
 
         if ($table) {
@@ -449,7 +451,7 @@
         if (!$this->db_handle)
             $this->db_connect('r');
 
-        return $this->db_handle->quote($input, $type);
+        return $this->db_connected ? $this->db_handle->quote($input, $type) : addslashes($input);
     }
 
 
@@ -480,7 +482,7 @@
         if (!$this->db_handle)
             $this->db_connect('r');
 
-        return $this->db_handle->quoteIdentifier($str);
+        return $this->db_connected ? $this->db_handle->quoteIdentifier($str) : $str;
     }
 
 

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list