Skip to content
Snippets Groups Projects
Commit 2c915aec authored by Jesse Norell's avatar Jesse Norell
Browse files

add config variable name prefix

parent b1210f0a
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,8 @@ class db ...@@ -35,6 +35,8 @@ class db
private $_iQueryId; private $_iQueryId;
private $_iConnId; private $_iConnId;
private $_Prefix = ''; // config variable name prefix
private $dbHost = ''; // hostname of the MySQL server private $dbHost = ''; // hostname of the MySQL server
private $dbPort = ''; // port of the MySQL server private $dbPort = ''; // port of the MySQL server
private $dbName = ''; // logical database name on that server private $dbName = ''; // logical database name on that server
...@@ -64,17 +66,18 @@ class db ...@@ -64,17 +66,18 @@ class db
*/ */
// constructor // constructor
public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL, $flags = NULL) { public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL, $flags = NULL, $confPrefix = '') {
global $app, $conf; global $app, $conf;
$this->dbHost = $host ? $host : $conf['db_host']; if($confPrefix != '') $this->_Prefix = $confPrefix . '_';
$this->dbPort = $port ? $port : $conf['db_port']; $this->dbHost = $host ? $host : $conf[$this->_Prefix.'db_host'];
$this->dbName = $database ? $database : $conf['db_database']; $this->dbPort = $port ? $port : $conf[$this->_Prefix.'db_port'];
$this->dbUser = $user ? $user : $conf['db_user']; $this->dbName = $database ? $database : $conf[$this->_Prefix.'db_database'];
$this->dbPass = $pass ? $pass : $conf['db_password']; $this->dbUser = $user ? $user : $conf[$this->_Prefix.'db_user'];
$this->dbCharset = $conf['db_charset']; $this->dbPass = $pass ? $pass : $conf[$this->_Prefix.'db_password'];
$this->dbNewLink = $conf['db_new_link']; $this->dbCharset = $conf[$this->_Prefix.'db_charset'];
$this->dbClientFlags = $flags ? $flags : $conf['db_client_flags']; $this->dbNewLink = $conf[$this->_Prefix.'db_new_link'];
$this->dbClientFlags = $flags ? $flags : $conf[$this->_Prefix.'db_client_flags'];
$this->_iConnId = mysqli_init(); $this->_iConnId = mysqli_init();
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags); mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
...@@ -187,7 +190,6 @@ class db ...@@ -187,7 +190,6 @@ class db
private function _query($sQuery = '') { private function _query($sQuery = '') {
global $app; global $app;
//if($this->isConnected == false) return false;
if ($sQuery == '') { if ($sQuery == '') {
$this->_sqlerror('Keine Anfrage angegeben / No query given'); $this->_sqlerror('Keine Anfrage angegeben / No query given');
return false; return false;
...@@ -211,7 +213,7 @@ class db ...@@ -211,7 +213,7 @@ class db
} }
if($try > 9) { if($try > 9) {
$this->_sqlerror('DB::query -> reconnect', '', true); $this->_sqlerror('DB::_query -> reconnect', '', true);
return false; return false;
} else { } else {
sleep(($try > 7 ? 5 : 1)); sleep(($try > 7 ? 5 : 1));
...@@ -474,7 +476,7 @@ class db ...@@ -474,7 +476,7 @@ class db
//$sAddMsg .= getDebugBacktrace(); //$sAddMsg .= getDebugBacktrace();
if($this->show_error_messages && $conf['demo_mode'] === false) { if($this->show_error_messages && $conf[$this->_Prefix.'demo_mode'] === false) {
echo $sErrormsg . $sAddMsg; echo $sErrormsg . $sAddMsg;
} elseif(is_object($app) && method_exists($app, 'log') && $bNoLog == false) { } elseif(is_object($app) && method_exists($app, 'log') && $bNoLog == false) {
$app->log($sErrormsg . $sAddMsg . ' -> ' . $mysql_errno . ' (' . $mysql_error . ')', LOGLEVEL_WARN, false); $app->log($sErrormsg . $sAddMsg . ' -> ' . $mysql_errno . ' (' . $mysql_error . ')', LOGLEVEL_WARN, false);
...@@ -570,7 +572,7 @@ class db ...@@ -570,7 +572,7 @@ class db
//** Function to fill the datalog with a full differential record. //** Function to fill the datalog with a full differential record.
public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new, $force_update = false) { public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new, $force_update = false) {
global $app, $conf; global $app;
// Insert backticks only for incomplete table names. // Insert backticks only for incomplete table names.
if(stristr($db_table, '.')) { if(stristr($db_table, '.')) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment