@@ -64,7 +64,7 @@ class db
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,19 +74,16 @@ 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 ' ];
78-
77+ $ this ->dbClientFlags = $ flags ? $ flags : $ conf ['db_client_flags ' ];
7978 $ this ->_iConnId = mysqli_init ();
80- $ this ->_iConnId ->real_connect ($ this ->dbHost , $ this ->dbUser , $ this ->dbPass , null , (int )$ this ->dbPort , null , $ this ->dbClientFlags );
81- $ try = 0 ;
82- while ($ this ->_iConnId ->connect_error && $ try < 5 ) {
83- if ($ try > 0 ) sleep (1 );
8479
85- $ try ++;
86- $ this ->_iConnId ->real_connect ($ this ->dbHost , $ this ->dbUser , $ this ->dbPass , null , (int )$ this ->dbPort , null , $ this ->dbClientFlags );
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 );
8784 }
8885
89- if ($ this ->_iConnId -> connect_error ) {
86+ if (! is_object ( $ this ->_iConnId ) || mysqli_connect_error () ) {
9087 $ this ->_iConnId = null ;
9188 $ this ->_sqlerror ('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible! ' , '' , true );
9289 return false ;
@@ -198,7 +195,7 @@ private function _query($sQuery = '') {
198195 $ try ++;
199196 $ ok = mysqli_ping ($ this ->_iConnId );
200197 if (!$ ok ) {
201- 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 )) {
202199 if ($ this ->errorNumber == '111 ' ) {
203200 // server is not available
204201 if ($ try > 9 ) {
0 commit comments