Re: switching DB's
| From: | Stig S. Bakken | Date: | Mon, 15 Apr 2002 20:09:22 +0000 |
| Subject: | Re: switching DB's | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-1143@lists.php.net to get a copy of this message | ||
Agreed.
- Stig
On Mon, 2002-04-15 at 20:30, derek fong wrote:
> Hi,
>
> It seems to me that the mysql_select_db() functionality should be abstracted
> into a setDatabase() (internal?) method anyway. This way, in case formal
> support (or maybe even hacks) is eventually added to allow other databases
> to specify the database to use, it can be added into the setDatabase()
> method while those databases that don't support this functionality can
> return a DB_ERROR_UNSUPPPORTED error or something.
>
> Just my thoughts anyway...
>
> -f
>
>
> On 04.15.2002 3:39 am, "Stig S. Bakken" <ssb@fast.no> wrote:
>
> > On Sun, 2002-04-14 at 22:42, Tomas V.V.Cox wrote:
> >> "Stig S. Bakken" wrote:
> >>>
> >>> On Sun, 2002-04-14 at 01:05, destr0 wrote:
> >>>> I have information in several different databases that I need to access.
> >>>> With my current database abstraction layer I make use of the
> >>>> mysql_select_db() function to switch databases on the fly between queries.
> >>>>
> >>>> The last time I looked the only way I could change databases with pear was
> >>>> by opening a second connection with a second dsn. Is there any way with
> >>>> pear to open a connection once and then switch databases on the same
> >>>> connection without opening a second connection?
> >>>
> >>> We could add a setDatabase method. What do people think? Tomas?
> >>>
> >>
> >> The mysql driver already do what Destr0 say.
> >>
> >> $db1 = DB::connect('mysql://root@localhost/db1');
> >> $dbN = DB::connect('mysql://root@localhost/dbN');
> >>
> >> Internally the same connection is used but PEAR DB switchs on the fly
> >> the database with mysql_select_db().
> >>
> >> I don't see the real need for adding setDatabase.
> >
> > But this is just a side-effect of the mysql connect implementation. If
> > there is a way to switch database on the same connection in other
> > databases, relying on a mysql side-effect to give the model for how it
> > should be done for all of them is really bad. But if it can't be done
> > in other databases, having setDatabase() won't make sense either.
> >
> > - Stig
> >