Commit 88240a91 authored by Marius Burkard's avatar Marius Burkard

Merge branch 'feature/4558-mysql-connect-with-client-flags' into 'stable-3.1'

MySQL connect with client flags. Fixes #4558

See merge request ispconfig/ispconfig3!798
parents 416cda95 a1c15afc
...@@ -75,16 +75,17 @@ class db { ...@@ -75,16 +75,17 @@ class db {
$this->dbNewLink = $conf[$prefix.'db_new_link']; $this->dbNewLink = $conf[$prefix.'db_new_link'];
$this->dbClientFlags = $conf[$prefix.'db_client_flags']; $this->dbClientFlags = $conf[$prefix.'db_client_flags'];
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort); $this->_iConnId = mysqli_init();
$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
$try = 0; $try = 0;
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) { while($this->_iConnId->connect_error && $try < 5) {
if($try > 0) sleep(1); if($try > 0) sleep(1);
$try++; $try++;
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort); $this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
} }
if(!is_object($this->_iConnId) || mysqli_connect_error()) { if($this->_iConnId->connect_error) {
$this->_iConnId = null; $this->_iConnId = null;
$this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!'); $this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!');
return false; return false;
......
...@@ -76,16 +76,17 @@ class db ...@@ -76,16 +76,17 @@ class db
$this->dbNewLink = $conf['db_new_link']; $this->dbNewLink = $conf['db_new_link'];
$this->dbClientFlags = $conf['db_client_flags']; $this->dbClientFlags = $conf['db_client_flags'];
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort); $this->_iConnId = mysqli_init();
$this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
$try = 0; $try = 0;
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) { while($this->_iConnId->connect_error && $try < 5) {
if($try > 0) sleep(1); if($try > 0) sleep(1);
$try++; $try++;
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort); $this->_iConnId->real_connect($this->dbHost, $this->dbUser, $this->dbPass, null, (int)$this->dbPort, null, $this->dbClientFlags);
} }
if(!is_object($this->_iConnId) || mysqli_connect_error()) { if($this->_iConnId->connect_error) {
$this->_iConnId = null; $this->_iConnId = null;
$this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!', '', true); $this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!', '', true);
return false; return false;
......
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