Re: DB connections with more databases

From: Date: Thu, 02 Dec 2004 00:41:25 +0000
Subject: Re: DB connections with more databases
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-15957@lists.php.net to get a copy of this message
On Wed, 1 Dec 2004 08:43:29 +0100, Sönke Ruempler <ruempler@topconcepts.com> wrote: > Justin Patrin wrote on Monday, November 15, 2004 8:00 PM: > > > On Mon, 15 Nov 2004 13:28:36 +0100, Sönke Ruempler > > <ruempler@topconcepts.com> wrote: > >> Hi, > >> > >> i noticed that i can't change the database within a pear object, > >> because DB sets the db before each query. Now i have a mysql server > >> with 4 databases and i need to use them all. I could make 4 DB > >> database connections, but that is really ugly and much overhead. Any > >> solution? > >> > > > > The best solution is to prefix your table names with the db name: > > > > SELECT * FROM database.table > > I noticed that there is a hint in the mysql.php code that a method for > setting the database in runtime should be implemented, atm it's only the _db > member variable. Imho setting the database for *each* query is unnecessary > overhead. > > If I am wrong, please correct me :) > It's set for each query because the mysql backend in PHP (in some versions, not sure if it's still a problem) set the database on *all* connections to the same server. So if you have 2 DB instances to different dbs, you have to re-set it for every query to make sure it's correct. -- Justin Patrin

« previous php.pear.general (#15957) next »