thomascube
2011-04-19 7342bb8b7a5e7f532f5e0cc2a423f02533a63ad4
Check for DB connection state instead of handle (handle could be an error object)

1 files modified
14 ■■■■■ changed files
program/include/rcube_mdb2.php 14 ●●●●● patch | view | raw | blame | history
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,6 +142,8 @@
        $this->db_handle = $this->dsn_connect($dsn);
        $this->db_connected = !PEAR::isError($this->db_handle);
        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;
    }