Bugs item #589598, was opened at 2002-08-01 22:34
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=403611&aid=589598&group_id=31885
Category: DB_SQL
Group: current CVS
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Incorrect DB select implementation
Initial Comment:
Within the DB_MYSQL file and other variants the
mysql_select_db is placed inside the if the statement
which checks for an open link/chan, this means that if
you connect to mysql outside of php using pconnect
when php_lib tries to write to the session tables it thinks
it has an open link/chan and assumes that it already
has selected the correct database.
You will notice below that this implementation always
executes the mysql_select_db regardless of if a
connection exists or not. This forces selection of the
correct phplib database.
To fix I have moded function as follows:
/* 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, \)
failed.");
return 0;
}
}
/* select database */
if (!@mysql_select_db($Database,$this->Link_ID)) {
$this->halt("cannot use database ".$this-
>Database);
return 0;
}
return $this->Link_ID;
}
----------------------------------------------------------------------
>Comment By: Ignatius Teo (eyrie)
Date: 2002-08-04 17:51
Message:
Logged In: YES
user_id=29397
This is not a bug. The correct implementation is to subclass
DB_Sql and point it to the appropriate database. That way,
the object's linkID will always point to the correct open
link/channel to the correct database.
Ignatius
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=403611&aid=589598&group_id=31885
|