@@ -35,6 +35,8 @@ class db
3535 private $ _iQueryId ;
3636 private $ _iConnId ;
3737
38+ private $ _Prefix = '' ; // config variable name prefix
39+
3840 private $ dbHost = '' ; // hostname of the MySQL server
3941 private $ dbPort = '' ; // port of the MySQL server
4042 private $ dbName = '' ; // logical database name on that server
@@ -64,17 +66,18 @@ class db
6466 */
6567
6668 // constructor
67- public function __construct ($ host = NULL , $ user = NULL , $ pass = NULL , $ database = NULL , $ port = NULL , $ flags = NULL ) {
69+ public function __construct ($ host = NULL , $ user = NULL , $ pass = NULL , $ database = NULL , $ port = NULL , $ flags = NULL , $ confPrefix = '' ) {
6870 global $ app , $ conf ;
6971
70- $ this ->dbHost = $ host ? $ host : $ conf ['db_host ' ];
71- $ this ->dbPort = $ port ? $ port : $ conf ['db_port ' ];
72- $ this ->dbName = $ database ? $ database : $ conf ['db_database ' ];
73- $ this ->dbUser = $ user ? $ user : $ conf ['db_user ' ];
74- $ this ->dbPass = $ pass ? $ pass : $ conf ['db_password ' ];
75- $ this ->dbCharset = $ conf ['db_charset ' ];
76- $ this ->dbNewLink = $ conf ['db_new_link ' ];
77- $ this ->dbClientFlags = $ flags ? $ flags : $ conf ['db_client_flags ' ];
72+ if ($ confPrefix != '' ) $ this ->_Prefix = $ confPrefix . '_ ' ;
73+ $ this ->dbHost = $ host ? $ host : $ conf [$ this ->_Prefix .'db_host ' ];
74+ $ this ->dbPort = $ port ? $ port : $ conf [$ this ->_Prefix .'db_port ' ];
75+ $ this ->dbName = $ database ? $ database : $ conf [$ this ->_Prefix .'db_database ' ];
76+ $ this ->dbUser = $ user ? $ user : $ conf [$ this ->_Prefix .'db_user ' ];
77+ $ this ->dbPass = $ pass ? $ pass : $ conf [$ this ->_Prefix .'db_password ' ];
78+ $ this ->dbCharset = $ conf [$ this ->_Prefix .'db_charset ' ];
79+ $ this ->dbNewLink = $ conf [$ this ->_Prefix .'db_new_link ' ];
80+ $ this ->dbClientFlags = $ flags ? $ flags : $ conf [$ this ->_Prefix .'db_client_flags ' ];
7881 $ this ->_iConnId = mysqli_init ();
7982
8083 mysqli_real_connect ($ this ->_iConnId , $ this ->dbHost , $ this ->dbUser , $ this ->dbPass , '' , (int )$ this ->dbPort , NULL , $ this ->dbClientFlags );
@@ -187,7 +190,6 @@ private function _setCharset() {
187190 private function _query ($ sQuery = '' ) {
188191 global $ app ;
189192
190- //if($this->isConnected == false) return false;
191193 if ($ sQuery == '' ) {
192194 $ this ->_sqlerror ('Keine Anfrage angegeben / No query given ' );
193195 return false ;
@@ -211,7 +213,7 @@ private function _query($sQuery = '') {
211213 }
212214
213215 if ($ try > 9 ) {
214- $ this ->_sqlerror ('DB::query -> reconnect ' , '' , true );
216+ $ this ->_sqlerror ('DB::_query -> reconnect ' , '' , true );
215217 return false ;
216218 } else {
217219 sleep (($ try > 7 ? 5 : 1 ));
@@ -474,7 +476,7 @@ private function _sqlerror($sErrormsg = 'Unbekannter Fehler', $sAddMsg = '', $bN
474476
475477 //$sAddMsg .= getDebugBacktrace();
476478
477- if ($ this ->show_error_messages && $ conf ['demo_mode ' ] === false ) {
479+ if ($ this ->show_error_messages && $ conf [$ this -> _Prefix . 'demo_mode ' ] === false ) {
478480 echo $ sErrormsg . $ sAddMsg ;
479481 } elseif (is_object ($ app ) && method_exists ($ app , 'log ' ) && $ bNoLog == false ) {
480482 $ app ->log ($ sErrormsg . $ sAddMsg . ' -> ' . $ mysql_errno . ' ( ' . $ mysql_error . ') ' , LOGLEVEL_WARN , false );
@@ -570,7 +572,7 @@ public function getDatabaseSize($database_name) {
570572
571573 //** Function to fill the datalog with a full differential record.
572574 public function datalogSave ($ db_table , $ action , $ primary_field , $ primary_id , $ record_old , $ record_new , $ force_update = false ) {
573- global $ app, $ conf ;
575+ global $ app ;
574576
575577 // Insert backticks only for incomplete table names.
576578 if (stristr ($ db_table , '. ' )) {
0 commit comments