Commit 05fe4041 authored by Till Brehm's avatar Till Brehm
Browse files

Merge branch 'sql_flags' into 'master'

added support for sql flags

this adds support for MySQL SSL encryption between servers in multiserver setup

See merge request !573
parents 3d069dfc 979e790c
......@@ -75,14 +75,12 @@ class db extends mysqli
$this->dbCharset = $conf[$prefix.'db_charset'];
$this->dbNewLink = $conf[$prefix.'db_new_link'];
$this->dbClientFlags = $conf[$prefix.'db_client_flags'];
$this->_iConnId = mysqli_init();
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
$try = 0;
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) {
if($try > 0) sleep(1);
$try++;
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
for($try=0;(!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5;++$try) {
sleep($try);
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
}
if(!is_object($this->_iConnId) || mysqli_connect_error()) {
......@@ -244,7 +242,7 @@ class db extends mysqli
$try++;
$ok = mysqli_ping($this->_iConnId);
if(!$ok) {
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
if($try > 4) {
$this->_sqlerror('DB::query -> reconnect');
return false;
......
......@@ -51,7 +51,7 @@ class app {
*/
if($conf['dbmaster_host'] != '' && ($conf['dbmaster_host'] != $conf['db_host'] || ($conf['dbmaster_host'] == $conf['db_host'] && $conf['dbmaster_database'] != $conf['db_database']))) {
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port']);
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port'], $conf['dbmaster_client_flags']);
} else {
$this->dbmaster = $this->db;
}
......
......@@ -64,7 +64,7 @@ class db extends mysqli
*/
// constructor
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL) {
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL, $flags = NULL) {
global $app, $conf;
$this->dbHost = $host ? $host : $conf['db_host'];
......@@ -74,15 +74,13 @@ class db extends mysqli
$this->dbPass = $pass ? $pass : $conf['db_password'];
$this->dbCharset = $conf['db_charset'];
$this->dbNewLink = $conf['db_new_link'];
$this->dbClientFlags = $conf['db_client_flags'];
$this->dbClientFlags = $flags ? $flags : $conf['db_client_flags'];
$this->_iConnId = mysqli_init();
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
$try = 0;
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) {
if($try > 0) sleep(1);
$try++;
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
for($try=0;(!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5;++$try) {
sleep($try);
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
}
if(!is_object($this->_iConnId) || mysqli_connect_error()) {
......@@ -197,7 +195,7 @@ class db extends mysqli
$try++;
$ok = mysqli_ping($this->_iConnId);
if(!$ok) {
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
if($this->errorNumber == '111') {
// server is not available
if($try > 9) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment