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