Added the ability to use persistent connections

This commit is contained in:
Dmitry Simushev 2011-11-08 16:42:41 +00:00 committed by Dmitriy Simushev
parent 11fa45cb19
commit b54cd674e6
2 changed files with 12 additions and 4 deletions

View File

@ -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);

View File

@ -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 */
?>
?>