Below is the code from db_mysql.inc, i had
modify the code to switch database :
/ public: connection management /
function connect($Database = "", $Host = "", $User = "", $Password = "") {
/* Handle defaults */
if ("" == $Database)
$Database = $this->Database;
if ("" == $Host)
$Host = $this->Host;
if ("" == $User)
$User = $this->User;
if ("" == $Password)
$Password = $this->Password;
/* establish connection, select database */
if ( 0 == $this->Link_ID ) {
$this->Link_ID=mysql_pconnect($Host, $User, $Password);
if (!$this->Link_ID) {
$this->halt("pconnect($Host, $User, \$Password) failed.");
return 0;
}
}
here the code i had change, bracket from
bottom already move to the top
I discover that $Database is lost in the if
function, anyone know what happen ??
if (!@mysql_select_db($Database,$this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
return 0;
}
return $this->Link_ID;
}
Following is the code i added to make it
works :
$this->Database = $Database;
$this->Database = $Database; code added
if (!@mysql_select_db($Database,$this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
return 0;
}
Althougt it works, but i still dont know why
it's work. Any help ? the major problem is
$database value is lost.