Changeset 3978 in subversion


Ignore:
Timestamp:
Sep 21, 2010 2:43:24 AM (3 years ago)
Author:
thomasb
Message:

Fix selection of read/write db connection

Location:
trunk/roundcubemail/program/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcmail.php

    r3967 r3978  
    237237      $this->db->sqlite_initials = INSTALL_PATH . 'SQL/sqlite.initial.sql'; 
    238238      $this->db->set_debug((bool)$config_all['sql_debug']); 
    239       $this->db->db_connect('w'); 
    240239    } 
    241240 
  • trunk/roundcubemail/program/include/rcube_mdb2.php

    r3947 r3978  
    3131 * @author     Thomas Bruederli <roundcube@gmail.com> 
    3232 * @author     Lukas Kahwe Smith <smith@pooteeweet.org> 
    33  * @version    1.16 
     33 * @version    1.17 
    3434 * @link       http://pear.php.net/package/MDB2 
    3535 */ 
     
    122122    function db_connect($mode) 
    123123    { 
    124         $this->db_mode = $mode; 
    125  
    126124        // Already connected 
    127125        if ($this->db_connected) { 
    128126            // no replication, current connection is ok 
    129             if ($this->db_dsnw == $this->db_dsnr) 
     127            if (empty($this->db_dsnr) || $this->db_dsnw == $this->db_dsnr) 
    130128                return; 
    131129 
    132             // connected to master, current connection is ok 
     130            // connected to read-write db, current connection is ok 
    133131            if ($this->db_mode == 'w') 
    134132                return; 
     
    142140 
    143141        $this->db_handle = $this->dsn_connect($dsn); 
    144         $this->db_connected = true; 
     142        $this->db_connected = !PEAR::isError($this->db_handle); 
     143        $this->db_mode = $mode; 
    145144    } 
    146145 
     
    196195    function query() 
    197196    { 
    198         if (!$this->is_connected()) 
    199             return null; 
    200  
    201197        $params = func_get_args(); 
    202198        $query = array_shift($params); 
     
    243239 
    244240        $this->db_connect($mode); 
     241 
     242        // check connection before proceeding 
     243        if (!$this->is_connected()) 
     244            return null; 
    245245 
    246246        if ($this->db_provider == 'sqlite') 
Note: See TracChangeset for help on using the changeset viewer.