Skip to content

Commit 979e790

Browse files
author
ncomputers.org
committed
sql added support for flags
1 parent 3d069df commit 979e790

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

interface/lib/classes/db_mysql.inc.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ public function __construct($prefix = '') {
7575
$this->dbCharset = $conf[$prefix.'db_charset'];
7676
$this->dbNewLink = $conf[$prefix.'db_new_link'];
7777
$this->dbClientFlags = $conf[$prefix.'db_client_flags'];
78+
$this->_iConnId = mysqli_init();
7879

79-
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
80-
$try = 0;
81-
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) {
82-
if($try > 0) sleep(1);
83-
84-
$try++;
85-
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
80+
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
81+
for($try=0;(!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5;++$try) {
82+
sleep($try);
83+
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
8684
}
8785

8886
if(!is_object($this->_iConnId) || mysqli_connect_error()) {
@@ -244,7 +242,7 @@ private function _query($sQuery = '') {
244242
$try++;
245243
$ok = mysqli_ping($this->_iConnId);
246244
if(!$ok) {
247-
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
245+
if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
248246
if($try > 4) {
249247
$this->_sqlerror('DB::query -> reconnect');
250248
return false;

server/lib/app.inc.php

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function __construct() {
5151
*/
5252

5353
if($conf['dbmaster_host'] != '' && ($conf['dbmaster_host'] != $conf['db_host'] || ($conf['dbmaster_host'] == $conf['db_host'] && $conf['dbmaster_database'] != $conf['db_database']))) {
54-
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port']);
54+
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port'], $conf['dbmaster_client_flags']);
5555
} else {
5656
$this->dbmaster = $this->db;
5757
}

server/lib/classes/db_mysql.inc.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class db extends mysqli
6464
*/
6565

6666
// constructor
67-
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL) {
67+
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL, $flags = NULL) {
6868
global $app, $conf;
6969

7070
$this->dbHost = $host ? $host : $conf['db_host'];
@@ -74,15 +74,13 @@ public function __construct($host = NULL , $user = NULL, $pass = NULL, $database
7474
$this->dbPass = $pass ? $pass : $conf['db_password'];
7575
$this->dbCharset = $conf['db_charset'];
7676
$this->dbNewLink = $conf['db_new_link'];
77-
$this->dbClientFlags = $conf['db_client_flags'];
77+
$this->dbClientFlags = $flags ? $flags : $conf['db_client_flags'];
78+
$this->_iConnId = mysqli_init();
7879

79-
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
80-
$try = 0;
81-
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) {
82-
if($try > 0) sleep(1);
83-
84-
$try++;
85-
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
80+
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
81+
for($try=0;(!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5;++$try) {
82+
sleep($try);
83+
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
8684
}
8785

8886
if(!is_object($this->_iConnId) || mysqli_connect_error()) {
@@ -197,7 +195,7 @@ private function _query($sQuery = '') {
197195
$try++;
198196
$ok = mysqli_ping($this->_iConnId);
199197
if(!$ok) {
200-
if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) {
198+
if(!mysqli_real_connect(mysqli_init(), $this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort, NULL, $this->dbClientFlags)) {
201199
if($this->errorNumber == '111') {
202200
// server is not available
203201
if($try > 9) {

0 commit comments

Comments
 (0)