some more fine-tuning of Galera checks, backported persisten connection handling from ADOdb 5.x

This commit is contained in:
Ralf Becker 2015-07-19 08:35:27 +00:00
parent 8596fc49bc
commit 970078e970
2 changed files with 16 additions and 5 deletions

View File

@ -43,11 +43,11 @@ class ADODB_mysqli extends ADOConnection {
var $poorAffectedRows = true; var $poorAffectedRows = true;
var $clientFlags = 0; var $clientFlags = 0;
var $substr = "substring"; var $substr = "substring";
var $port = false; var $port = 3306;
var $socket = false; var $socket = '';
var $_bindInputArray = false; var $_bindInputArray = false;
var $nameQuote = '`'; /// string to use to quote identifiers and names var $nameQuote = '`'; /// string to use to quote identifiers and names
var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0)); var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0),array(MYSQLI_OPT_CONNECT_TIMEOUT,1));
function ADODB_mysqli() function ADODB_mysqli()
{ {
@ -86,6 +86,10 @@ class ADODB_mysqli extends ADOConnection {
} }
if (strstr($argHostname,':')) list($argHostname,$this->port) = explode(':',$argHostname); if (strstr($argHostname,':')) list($argHostname,$this->port) = explode(':',$argHostname);
//http ://php.net/manual/en/mysqli.persistconns.php
if ($persist && PHP_VERSION > 5.2 && strncmp($argHostname,'p:',2) != 0) $argHostname = 'p:'.$argHostname;
$ok = @mysqli_real_connect($this->_connectionID, $ok = @mysqli_real_connect($this->_connectionID,
$argHostname, $argHostname,
$argUsername, $argUsername,

View File

@ -382,6 +382,7 @@ class egw_db
* *
* To enable this check add the following to your header.inc.php: * To enable this check add the following to your header.inc.php:
* *
* require_once(EGW_API_INC.'/class.egw_db.inc.php');
* egw_db::$health_check = array('egw_db', 'galera_cluster_health'); * egw_db::$health_check = array('egw_db', 'galera_cluster_health');
* *
* @param egw_db $db already connected egw_db instance to check * @param egw_db $db already connected egw_db instance to check
@ -417,9 +418,15 @@ class egw_db
if ($next && ++$n >= $num_hosts+2) if ($next && ++$n >= $num_hosts+2)
{ {
return false; $n = 0; // start search again with default on next request
$ret = false;
} }
return $hosts[$n % $num_hosts]; else
{
$ret = $hosts[$n % $num_hosts];
}
//error_log(__METHOD__."(next=".array2string($next).") n=$n returning ".array2string($ret));
return $ret;
} }
/** /**