mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 13:17:24 +02:00
Merge pull request #3296 from Deltik/fix-test-6
Reduce reliance on global var $db_ConnectionID
This commit is contained in:
@@ -51,6 +51,7 @@ exclude_patterns:
|
|||||||
- "**/*.d.ts"
|
- "**/*.d.ts"
|
||||||
- "e107_admin/core_image.php"
|
- "e107_admin/core_image.php"
|
||||||
- "e107_plugins/log/js/awesomechart.js"
|
- "e107_plugins/log/js/awesomechart.js"
|
||||||
|
- "e107_core/**/*.sc"
|
||||||
- "e107_docs/**/*"
|
- "e107_docs/**/*"
|
||||||
- "e107_images/**/*"
|
- "e107_images/**/*"
|
||||||
- "e107_handlers/hybridauth/**/*"
|
- "e107_handlers/hybridauth/**/*"
|
||||||
|
@@ -483,11 +483,7 @@ class e_db_mysql
|
|||||||
$this->db_Write_log($log_type, $log_remark, $query);
|
$this->db_Write_log($log_type, $log_remark, $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
$b = microtime();
|
$b = microtime();
|
||||||
|
|
||||||
@@ -978,11 +974,7 @@ class e_db_mysql
|
|||||||
$query = 'INSERT INTO '.$this->mySQLPrefix."{$table} VALUES ({$arg})";
|
$query = 'INSERT INTO '.$this->mySQLPrefix."{$table} VALUES ({$arg})";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->mySQLresult = $this->db_Query($query, NULL, 'db_Insert', $debug, $log_type, $log_remark);
|
$this->mySQLresult = $this->db_Query($query, NULL, 'db_Insert', $debug, $log_type, $log_remark);
|
||||||
|
|
||||||
@@ -1197,11 +1189,7 @@ class e_db_mysql
|
|||||||
$table = $this->db_IsLang($tableName);
|
$table = $this->db_IsLang($tableName);
|
||||||
$this->mySQLcurTable = $table;
|
$this->mySQLcurTable = $table;
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
$arg = $this->_prepareUpdateArg($tableName, $arg);
|
$arg = $this->_prepareUpdateArg($tableName, $arg);
|
||||||
|
|
||||||
@@ -1459,11 +1447,7 @@ class e_db_mysql
|
|||||||
$table = $this->db_IsLang($table);
|
$table = $this->db_IsLang($table);
|
||||||
$this->mySQLcurTable = $table;
|
$this->mySQLcurTable = $table;
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_data = '';
|
$new_data = '';
|
||||||
if (is_array($vars))
|
if (is_array($vars))
|
||||||
@@ -1665,11 +1649,7 @@ class e_db_mysql
|
|||||||
*/
|
*/
|
||||||
function close()
|
function close()
|
||||||
{
|
{
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
e107::getSingleton('e107_traffic')->BumpWho('db Close', 1);
|
e107::getSingleton('e107_traffic')->BumpWho('db Close', 1);
|
||||||
$this->mySQLaccess = NULL; // correct way to do it when using shared links.
|
$this->mySQLaccess = NULL; // correct way to do it when using shared links.
|
||||||
$this->dbError('dbClose');
|
$this->dbError('dbClose');
|
||||||
@@ -1701,11 +1681,7 @@ class e_db_mysql
|
|||||||
$table = $this->db_IsLang($table);
|
$table = $this->db_IsLang($table);
|
||||||
$this->mySQLcurTable = $table;
|
$this->mySQLcurTable = $table;
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!$arg)
|
if (!$arg)
|
||||||
@@ -1907,11 +1883,7 @@ class e_db_mysql
|
|||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($multiple == FALSE)
|
if($multiple == FALSE)
|
||||||
{
|
{
|
||||||
@@ -2249,11 +2221,7 @@ class e_db_mysql
|
|||||||
$this->mySQLdefaultdb = $mySQLdefaultdb;
|
$this->mySQLdefaultdb = $mySQLdefaultdb;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($prefix == '') $prefix = $this->mySQLPrefix;
|
if ($prefix == '') $prefix = $this->mySQLPrefix;
|
||||||
|
|
||||||
@@ -2321,11 +2289,7 @@ class e_db_mysql
|
|||||||
$convert = array("PRIMARY"=>"PRI","INDEX"=>"MUL","UNIQUE"=>"UNI");
|
$convert = array("PRIMARY"=>"PRI","INDEX"=>"MUL","UNIQUE"=>"UNI");
|
||||||
$key = (isset($convert[$key])) ? $convert[$key] : "OFF";
|
$key = (isset($convert[$key])) ? $convert[$key] : "OFF";
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $this->gen("SHOW COLUMNS FROM ".$this->mySQLPrefix.$table);
|
$result = $this->gen("SHOW COLUMNS FROM ".$this->mySQLPrefix.$table);
|
||||||
if ($result && ($this->rowCount() > 0))
|
if ($result && ($this->rowCount() > 0))
|
||||||
@@ -2373,11 +2337,7 @@ class e_db_mysql
|
|||||||
$this->mySQLdefaultdb = $mySQLdefaultdb;
|
$this->mySQLdefaultdb = $mySQLdefaultdb;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($fields) && !is_array($fields))
|
if (!empty($fields) && !is_array($fields))
|
||||||
{
|
{
|
||||||
@@ -2441,11 +2401,7 @@ class e_db_mysql
|
|||||||
$data = strip_if_magic($data);
|
$data = strip_if_magic($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->mySQLaccess)
|
$this->provide_mySQLaccess();
|
||||||
{
|
|
||||||
global $db_ConnectionID;
|
|
||||||
$this->mySQLaccess = $db_ConnectionID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->pdo)
|
if($this->pdo)
|
||||||
{
|
{
|
||||||
@@ -3141,10 +3097,38 @@ class e_db_mysql
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In case e_db_mysql::$mySQLaccess is not set, set it.
|
||||||
|
*
|
||||||
|
* Uses the global variable $db_ConnectionID if available.
|
||||||
|
*
|
||||||
|
* When the global variable has been unset like in https://github.com/e107inc/e107-test/issues/6 ,
|
||||||
|
* use the "mySQLaccess" from the default e_db_mysql instance singleton.
|
||||||
|
*/
|
||||||
|
private function provide_mySQLaccess()
|
||||||
|
{
|
||||||
|
if (!$this->mySQLaccess) {
|
||||||
|
global $db_ConnectionID;
|
||||||
|
$this->mySQLaccess = $db_ConnectionID;
|
||||||
|
}
|
||||||
|
if (!$this->mySQLaccess) {
|
||||||
|
$this->mySQLaccess = e107::getDb()->get_mySQLaccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BC
|
* @deprecated 2.1.9 Used only to provide $mySQLaccess to other instances of e_db_mysql scattered around
|
||||||
|
* @return PDO
|
||||||
|
*/
|
||||||
|
public function get_mySQLaccess()
|
||||||
|
{
|
||||||
|
return $this->mySQLaccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backwards compatibility
|
||||||
*/
|
*/
|
||||||
class db extends e_db_mysql
|
class db extends e_db_mysql
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user