@@ -36,6 +36,7 @@ class db
3636 private $ _iConnId ;
3737
3838 private $ dbHost = '' ; // hostname of the MySQL server
39+ private $ dbPort = '' ; // port of the MySQL server
3940 private $ dbName = '' ; // logical database name on that server
4041 private $ dbUser = '' ; // database authorized user
4142 private $ dbPass = '' ; // user's password
@@ -68,21 +69,22 @@ private function do_connect() {
6869 global $ conf ;
6970
7071 if ($ this ->_iConnId ) return true ;
71- $ this ->dbHost = $ conf ["mysql " ]["host " ];
72+ $ this ->dbHost = $ conf ['mysql ' ]['port ' ];
73+ $ this ->dbPort = $ conf [$ prefix .'db_port ' ];
7274 $ this ->dbName = false ;//$conf["mysql"]["database"];
7375 $ this ->dbUser = $ conf ["mysql " ]["admin_user " ];
7476 $ this ->dbPass = $ conf ["mysql " ]["admin_password " ];
7577 $ this ->dbCharset = $ conf ["mysql " ]["charset " ];
7678 $ this ->dbNewLink = false ;
7779 $ this ->dbClientFlags = null ;
7880
79- $ this ->_iConnId = mysqli_connect ($ this ->dbHost , $ this ->dbUser , $ this ->dbPass );
81+ $ this ->_iConnId = mysqli_connect ($ this ->dbHost , $ this ->dbUser , $ this ->dbPass , ( int ) $ this -> dbPort );
8082 $ try = 0 ;
8183 while ((!is_object ($ this ->_iConnId ) || mysqli_connect_error ()) && $ try < 5 ) {
8284 if ($ try > 0 ) sleep (1 );
8385
8486 $ try ++;
85- $ this ->_iConnId = mysqli_connect ($ this ->dbHost , $ this ->dbUser , $ this ->dbPass );
87+ $ this ->_iConnId = mysqli_connect ($ this ->dbHost , $ this ->dbUser , $ this ->dbPass , ( int ) $ this -> dbPort );
8688 }
8789
8890 if (!is_object ($ this ->_iConnId ) || mysqli_connect_error ()) {
@@ -96,10 +98,11 @@ private function do_connect() {
9698 $ this ->_setCharset ();
9799 }
98100
99- public function setDBData ($ host , $ user , $ password ) {
101+ public function setDBData ($ host , $ user , $ password, $ port ) {
100102 $ this ->dbHost = $ host ;
101103 $ this ->dbUser = $ user ;
102104 $ this ->dbPass = $ password ;
105+ $ this ->dbPort = $ port ;
103106 }
104107
105108 public function setDBName ($ name ) {
@@ -201,7 +204,7 @@ private function _query($sQuery = '') {
201204 $ try ++;
202205 $ ok = mysqli_ping ($ this ->_iConnId );
203206 if (!$ ok ) {
204- if (!mysqli_connect ($ this ->dbHost , $ this ->dbUser , $ this ->dbPass , $ this ->dbName )) {
207+ if (!mysqli_connect ($ this ->dbHost , $ this ->dbUser , $ this ->dbPass , $ this ->dbName , ( int ) $ this -> dbPort )) {
205208 if ($ this ->errorNumber == '111 ' ) {
206209 // server is not available
207210 if ($ try > 9 ) {
0 commit comments