diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-09-21 06:43:24 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-09-21 06:43:24 +0000 |
| commit | 076fee24179cb0b1c2be4a617c43f8010b30c776 (patch) | |
| tree | c5c7855ffaac5c4629e90f6e5369ebfbfb9afbf3 /roundcubemail/program | |
| parent | b32207d5e1bfc68001b81d21aac2d511ce0c979e (diff) | |
Fix selection of read/write db connection
git-svn-id: https://svn.roundcube.net/trunk@3978 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program')
| -rw-r--r-- | roundcubemail/program/include/rcmail.php | 1 | ||||
| -rw-r--r-- | roundcubemail/program/include/rcube_mdb2.php | 18 |
2 files changed, 9 insertions, 10 deletions
diff --git a/roundcubemail/program/include/rcmail.php b/roundcubemail/program/include/rcmail.php index e91111975..97d4b54f9 100644 --- a/roundcubemail/program/include/rcmail.php +++ b/roundcubemail/program/include/rcmail.php @@ -236,7 +236,6 @@ class rcmail $this->db = new rcube_mdb2($config_all['db_dsnw'], $config_all['db_dsnr'], $config_all['db_persistent']); $this->db->sqlite_initials = INSTALL_PATH . 'SQL/sqlite.initial.sql'; $this->db->set_debug((bool)$config_all['sql_debug']); - $this->db->db_connect('w'); } return $this->db; diff --git a/roundcubemail/program/include/rcube_mdb2.php b/roundcubemail/program/include/rcube_mdb2.php index cecb7ab65..84b6e2f62 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.16 + * @version 1.17 * @link http://pear.php.net/package/MDB2 */ class rcube_mdb2 @@ -121,15 +121,13 @@ class rcube_mdb2 */ 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) + if (empty($this->db_dsnr) || $this->db_dsnw == $this->db_dsnr) 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 +139,8 @@ class rcube_mdb2 $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 +194,6 @@ class rcube_mdb2 */ function query() { - if (!$this->is_connected()) - return null; - $params = func_get_args(); $query = array_shift($params); @@ -243,6 +239,10 @@ class rcube_mdb2 $this->db_connect($mode); + // check connection before proceeding + if (!$this->is_connected()) + return null; + if ($this->db_provider == 'sqlite') $this->_sqlite_prepare(); |
