mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
Support multiple database connections for the same mysql-user.
This commit is contained in:
@@ -328,7 +328,10 @@ class e_db_mysql
|
|||||||
$this->db_Set_Charset();
|
$this->db_Set_Charset();
|
||||||
$this->setSQLMode();
|
$this->setSQLMode();
|
||||||
|
|
||||||
if ($db_ConnectionID == NULL){ $db_ConnectionID = $this->mySQLaccess; }
|
//if ($db_ConnectionID == NULL){
|
||||||
|
$db_ConnectionID = $this->mySQLaccess;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -347,17 +350,25 @@ class e_db_mysql
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Select the database to use.
|
* Select the database to use.
|
||||||
* @param string database name
|
* @param string $database name
|
||||||
* @param string table prefix . eg. e107_
|
* @param string $table prefix . eg. e107_
|
||||||
|
* @param boolean $multiple set to maintain connection to a secondary database.
|
||||||
* @return boolean true when database selection was successful otherwise false.
|
* @return boolean true when database selection was successful otherwise false.
|
||||||
*/
|
*/
|
||||||
public function database($database, $prefix = MPREFIX)
|
public function database($database, $prefix = MPREFIX, $multiple=false)
|
||||||
{
|
{
|
||||||
$this->mySQLdefaultdb = $database;
|
$this->mySQLdefaultdb = $database;
|
||||||
$this->mySQLPrefix = $prefix;
|
$this->mySQLPrefix = $prefix;
|
||||||
|
|
||||||
|
if($multiple === true)
|
||||||
|
{
|
||||||
|
$this->mySQLPrefix = "`".$database."`.".$prefix;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->pdo)
|
if($this->pdo)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->mySQLaccess->query("use ".$database);
|
$this->mySQLaccess->query("use ".$database);
|
||||||
@@ -1816,7 +1827,8 @@ class e_db_mysql
|
|||||||
$this->mySQLcurTable = $table;
|
$this->mySQLcurTable = $table;
|
||||||
$this->tabset = true;
|
$this->tabset = true;
|
||||||
}
|
}
|
||||||
return ' `'.$this->mySQLPrefix.$table.'`'.substr($matches[0],-1);
|
|
||||||
|
return " ".$this->mySQLPrefix.$table.substr($matches[0],-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user