Re: DB connections with more databases
| From: | Matthew Weier O'Phinney | Date: | Mon, 15 Nov 2004 20:05:43 +0000 |
| Subject: | Re: DB connections with more databases | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15541@lists.php.net to get a copy of this message | ||
* Justin Patrin <papercrane@gmail.com>:
> On Mon, 15 Nov 2004 13:28:36 +0100, Sönke Ruempler
> <ruempler@topconcepts.com> wrote:
> > 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 can immediately see an issue with this: what if each database needs a
different db user? This would require multiple connections -- or the
ability to connect to other databases after the object has been
instantiated.
--
Matthew Weier O'Phinney | mailto:matthew@garden.org
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org