Re: DB connections with more databases
| From: | Justin Patrin | Date: | Mon, 15 Nov 2004 21:12:56 +0000 |
| Subject: | Re: DB connections with more databases | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15547@lists.php.net to get a copy of this message | ||
On 15 Nov 2004 20:05:43 -0000, Matthew Weier O'Phinney
<matthew@garden.org> wrote:
> * 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.
>
The OP said that they didn't want to connect multiple times. AFAIK
it's not possible to "re-authenticate" a connection. If you need
different logins, then you should create multiple DB instances.
--
Justin Patrin