From b54cd674e6591dcca83724be9dfcb3e62c0cb178 Mon Sep 17 00:00:00 2001 From: Dmitry Simushev Date: Tue, 8 Nov 2011 16:42:41 +0000 Subject: [PATCH] Added the ability to use persistent connections --- src/messenger/webim/libs/common.php | 12 +++++++++--- src/messenger/webim/libs/config.php | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index 318cd29f..c688639f 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -344,12 +344,18 @@ function getgetparam($name, $default = '') function connect() { - global $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb, $dbencoding, $force_charset_in_connection; + global $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb, $dbencoding, $force_charset_in_connection, $use_persistent_connection; if (!extension_loaded("mysql")) { die('Mysql extension is not loaded'); } - $link = @mysql_connect($mysqlhost, $mysqllogin, $mysqlpass) - or die('Could not connect: ' . mysql_error()); + if ($use_persistent_connection) { + $link = @mysql_pconnect($mysqlhost, $mysqllogin, $mysqlpass); + }else{ + $link = @mysql_connect($mysqlhost, $mysqllogin, $mysqlpass); + } + if (! $link) { + die('Could not connect: ' . mysql_error()); + } mysql_select_db($mysqldb, $link) or die('Could not select database'); if ($force_charset_in_connection) { mysql_query("SET NAMES '$dbencoding'", $link); diff --git a/src/messenger/webim/libs/config.php b/src/messenger/webim/libs/config.php index 6d541b4e..90a2e203 100644 --- a/src/messenger/webim/libs/config.php +++ b/src/messenger/webim/libs/config.php @@ -41,6 +41,8 @@ $mysqlprefix = ""; $dbencoding = "utf8"; $force_charset_in_connection = true; +$use_persistent_connection = false; + /* * Mailbox */ @@ -53,4 +55,4 @@ $mail_encoding = "utf-8"; $home_locale = "en"; /* native name will be used in this locale */ $default_locale = "en"; /* if user does not provide known lang */ -?> \ No newline at end of file +?>