[Phplib-trackers] [ phplib-Bugs-589598 ] Incorrect DB select implementation
Brought to you by:
nhruby,
richardarcher
|
From: <no...@so...> - 2002-08-01 12:34:21
|
Bugs item #589598, was opened at 2002-08-01 05: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: Open 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; } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=403611&aid=589598&group_id=31885 |