Re: [Phplib-users] db_mysql.inc connect() & multiple databases
Brought to you by:
nhruby,
richardarcher
|
From: Michael C. <mdc...@mi...> - 2002-07-20 02:44:53
|
On Fri, Jul 19, 2002 at 03:38:09PM -0400, Mike Gifford wrote:
> Hello,
>
> I'm just looking at db_mysql.inc now and it looks to me like it is
> structured such that the database criticals need to be hard coded into
> the defaults for the file:
>
> function connect($Database = db $Host = "localhost", $User = "user",
> $Password = "password") {
>
> I can't see a way around this without rewriting this clas so that it
> does not depend on the connect() function only using the default
> values.
>
> Shouldn't it just be pulling $Database, $Host, $User & $Password from
> the main script's config file?
Actually, it's pulling those values from properties which are overridden
in a subclass. You should see something like this in local.inc:
class DB_Mine extends DB_Sql {
var $Host = "localhost";
var $Database = "mydb";
var $User = "mydbuser";
var $Password = "mydbpass";
}
Then, in your code:
$db = new DB_Mine;
I've found that it's often more convenient to put the subclass code
about into a file other than local.inc so that you can easily move
that file between a test and production environment which have
different databases.
Michael
--
Michael Darrin Chaney
mdc...@mi...
http://www.michaelchaney.com/
|