diff options
author | svncommit <devs@roundcube.net> | 2005-10-02 15:01:44 +0000 |
---|---|---|
committer | svncommit <devs@roundcube.net> | 2005-10-02 15:01:44 +0000 |
commit | 0f1bc4bf0351dd8b284c7b4b69d350e61164b138 (patch) | |
tree | 88b8f25ac82c22aafa7bdcf3c12b21660de155ca /program/include | |
parent | f5dc2a42a2b2a9b9e77c0a1513db3de21f709c41 (diff) |
added use of persistent links and improved non-replication connection
Diffstat (limited to 'program/include')
-rwxr-xr-x | program/include/rcube_db.inc | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/program/include/rcube_db.inc b/program/include/rcube_db.inc index f4dc222a5..87cb869f8 100755 --- a/program/include/rcube_db.inc +++ b/program/include/rcube_db.inc @@ -51,7 +51,9 @@ class rcube_db // Connect to specific database function dsn_connect($dsn) { - $dbh = DB::connect($dsn); + // Use persistent connections if available + + $dbh = DB::connect($dsn, array('persistent' => $true)); if (DB::isError($dbh)) raise_error(array('code' => 500, @@ -65,10 +67,20 @@ class rcube_db // Connect to appropiate databse function db_connect ($mode) { - if ($this->db_connected && $this->db_mode=='w') return; - - if ($this->db_connected && $this->db_mode==$mode) return; - + // Already connected + + if ($this->db_connected) + { + // no replication, current connection is ok + if ($this->db_dsnw==$this->db_dsnr) return; + + // connected to master, current connection is ok + if ($this->db_mode=='w') return; + + // Same mode, current connection is ok + if ($this->db_mode==$mode) return; + } + if ($mode=='r') $dsn=$this->db_dsnr; else |