alecpl
2010-09-25 e019f2d0f2dc2fbfa345ab5d7ae85e67bfdd76b8
program/include/rcube_mdb2.php
@@ -4,8 +4,8 @@
 +-----------------------------------------------------------------------+
 | program/include/rcube_mdb2.php                                        |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2005-2009, RoundCube Dev. - Switzerland                 |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland                 |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | PURPOSE:                                                              |
@@ -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.16
 * @version    1.17
 * @link       http://pear.php.net/package/MDB2
 */
class rcube_mdb2
@@ -121,15 +121,15 @@
     */
    function db_connect($mode)
    {
        $this->db_mode = $mode;
        // Already connected
        if ($this->db_connected) {
            // no replication, current connection is ok
            if ($this->db_dsnw == $this->db_dsnr)
            // no replication, current connection is ok for read and write
            if (empty($this->db_dsnr) || $this->db_dsnw == $this->db_dsnr) {
                $this->db_mode = 'w';
                return;
            }
            // connected to master, current connection is ok
            // connected to read-write db, current connection is ok
            if ($this->db_mode == 'w')
                return;
@@ -141,7 +141,8 @@
        $dsn = ($mode == 'r') ? $this->db_dsnr : $this->db_dsnw;
        $this->db_handle = $this->dsn_connect($dsn);
        $this->db_connected = true;
        $this->db_connected = !PEAR::isError($this->db_handle);
        $this->db_mode = $mode;
    }
@@ -195,9 +196,6 @@
     */
    function query()
    {
        if (!$this->is_connected())
            return null;
        $params = func_get_args();
        $query = array_shift($params);
@@ -242,6 +240,10 @@
        $mode = (strtolower(substr(trim($query),0,6)) == 'select') ? 'r' : 'w';
        $this->db_connect($mode);
        // check connection before proceeding
        if (!$this->is_connected())
            return null;
        if ($this->db_provider == 'sqlite')
            $this->_sqlite_prepare();
@@ -725,7 +727,8 @@
function mdb2_debug_handler(&$db, $scope, $message, $context = array())
{
    if ($scope != 'prepare') {
        $debug_output = $scope . '('.$db->db_index.'): ' . $message;
        $debug_output = sprintf('%s(%d): %s;',
            $scope, $db->db_index, rtrim($message, ';'));
        write_log('sql', $debug_output);
    }
}