diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-04-19 21:00:34 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-04-19 21:00:34 +0000 |
| commit | a9994a69126fb3186f5c2bfc3e5b5345c902c7f5 (patch) | |
| tree | c75de773d45ee33d89e39353aff81dd145b62e9b /roundcubemail/program/include | |
| parent | ce0c2a13af7937b40a52541521d401e89ce9e613 (diff) | |
Check for DB connection state instead of handle (handle could be an error object)
git-svn-id: https://svn.roundcube.net/trunk@4670 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include')
| -rw-r--r-- | roundcubemail/program/include/rcube_mdb2.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/roundcubemail/program/include/rcube_mdb2.php b/roundcubemail/program/include/rcube_mdb2.php index 7675e847f..707bce027 100644 --- a/roundcubemail/program/include/rcube_mdb2.php +++ b/roundcubemail/program/include/rcube_mdb2.php @@ -30,7 +30,7 @@ * @author David Saez Padros <david@ols.es> * @author Thomas Bruederli <roundcube@gmail.com> * @author Lukas Kahwe Smith <smith@pooteeweet.org> - * @version 1.17 + * @version 1.18 * @link http://pear.php.net/package/MDB2 */ class rcube_mdb2 @@ -142,7 +142,9 @@ class rcube_mdb2 $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 @@ class rcube_mdb2 */ 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 @@ class rcube_mdb2 */ 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 @@ class rcube_mdb2 */ 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 @@ class rcube_mdb2 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 @@ class rcube_mdb2 if (!$this->db_handle) $this->db_connect('r'); - return $this->db_handle->quoteIdentifier($str); + return $this->db_connected ? $this->db_handle->quoteIdentifier($str) : $str; } |
