No, it doesn't satisfy me at all.  Your application design is broken and
forcing multiple identical connections doesn't solve it at all.  You are
trying to associate a selected DB with a database connection artificially.

The proper way to do this in your generalized app would be to either force
a mysql_select_db on each query to make sure you are talking to the right
one, or if you prefer do a select database() query to see which is the
current one.

How do you ensure that some query doesn't come along and change the
database on you in your current design?  Having two identical connections
that only differ in the initially selected DB doesn't solve the problem of
keeping track of which DB is current in the generalized sense.

-Rasmus

On Mon, 22 Apr 2002, Markus Fischer wrote:

>     I first came across this issue when I wrote a general
>     database backend in PHP-GTK (last year, around same time). I
>     had different objects on their own all with their own mysql
>     resource handle.
>
>     Now guess what, opening two connections with same
>     user/pass/host causes nearly unpredictable results because
>     the application was event driven and it was imposible to
>     foresee which DB was the current one. I would have to call
>     mysql_select_db() before _every_ query in the objects. This
>     was still solveable, but become a problem until the use could
>     freely type in sql statements (use other_db) so I wasn't able
>     to track which db should be the current one for the next call
>     (I could have parsed the SQL statement .. well).
>
>     I hope this gives a more real-world sample ... though I'm not
>     sure if it satisfies you. It describes my intention behind
>     this and is the last thing I could add to the thread.
>
>     - Markus
>
> On Mon, Apr 22, 2002 at 05:42:02AM -0700, Rasmus Lerdorf wrote :
> > I am not arguing against it, I have just not seen any decent technical
> > reason to open two connections with the same credentials.  Avoiding a
> > mysql_select_db() call doesn't seem like a very good reason to me.
> >
> > -Rasmus
> >
> > On Mon, 22 Apr 2002, Markus Fischer wrote:
> >
> > >     Rasmus,
> > >
> > >     it has been desired by a few people including me to open
> > >     multiple connections to the same user/pass/host. If you do a
> > >     lot were you actually need it, and you forget to switch it one
> > >     time you can be in a lot trouble.
> > >
> > >     Also, honestly, I do not understand why PHP _forces_ you to
> > >     reuse the same links. Until the patch/optional parameter the
> > >     only workaround was to use another username (doh!).
> > >
> > >     I already talked to Yasou and he ensured me he will implement
> > >     a similar facility to pgsql extension (as much tied to mysql
> > >     as possible to be not too different). I've seen other native
> > >     DB drivers seem to 'suffer' from the same feature.
> > >
> > >     This feature on its own is good for new users. But until
> > >     recently it didn't gave a, let's say a more expirienced user
> > >     knowing what she does, the ability to solve from PHP side
> > >     (which is exactly what people complained; here on php-dev@
> > >     and also on pear-dev@).
> > >
> > >     my 2eurocents
> > >
> > >         - Markus
> > >
> > > On Mon, Apr 22, 2002 at 04:53:22AM -0700, Rasmus Lerdorf wrote :
> > > > Just curious, why do you need multiple identical connections?
> > > >
> > > > On Mon, 22 Apr 2002, Matthew Walker wrote:
> > > >
> > > > > Ahhh. Delighted to hear that. I'll upgrade as soon as there's an RPM
> > > > > available for RH7.1. (I'd compile it, but I always forget something, and
> > > > > I can't afford downtime on that server.)
> > > > >
> > > > > Thanks for everyone's help. May I never need it again. (I only mail
> > > > > developers when it's a /major issue.)
> > > > >
> > > > > Matthew Walker
> > > > > Senior Software Engineer
> > > > > ePliant Marketing
> > > > >
> > > > >
> > > > > -----Original Message-----
> > > > > From: Markus Fischer [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Monday, April 22, 2002 6:50 AM
> > > > > To: Matthew Walker
> > > > > Cc: [EMAIL PROTECTED]
> > > > > Subject: Re: [PHP-DEV] Major Bug in multiple MySQL Connections?
> > > > >
> > > > >     Hello Matthew,
> > > > >
> > > > >     you should read my commect on this bug report too. 4.2.0
> > > > >     which will be released soon contains already a workaround for
> > > > >     this limitation.
> > > > >
> > > > >     - Markus
> > > > >
> > > > > On Mon, Apr 22, 2002 at 06:41:44AM -0600, Matthew Walker wrote :
> > > > > > I believe I may have found a major bug in the use of multiple MySQL
> > > > > > connections. Please see my bug report at HYPERLINK
> > > > > >
> > > > > "http://bugs.php.net/bug.php?id=16730"http://bugs.php.net/bug.php?id=167
> > > > > > 30. If I?m wrong about this, please tell me how to fix it. This is a
> > > > > > showstopper bug for the software I?m currently working on.
> > > > > >
> > > > > > Matthew Walker
> > > > > > Senior Software Engineer
> > > > > > ePliant Marketing
> > > > > >
> > > > > >
> > > > > > ---
> > > > > > Outgoing mail is certified Virus Free.
> > > > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > > Version: 6.0.345 / Virus Database: 193 - Release Date: 4/9/2002
> > > > > >
> > > > > >
> > > > > > --
> > > > > > PHP Development Mailing List <http://www.php.net/>
> > > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > > > --
> > > > > Please always Cc to me when replying to me on the lists.
> > > > > GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
> > > > > "Mind if I MFH ?" "What QA did you do on it?" "the usual?" "ah... none
> > > > > :)"
> > > > >
> > > > >
> > > > > ---
> > > > > Outgoing mail is certified Virus Free.
> > > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > > Version: 6.0.345 / Virus Database: 193 - Release Date: 4/9/2002
> > > > >
> > > > >
> > > > > --
> > > > > PHP Development Mailing List <http://www.php.net/>
> > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > >
> > > >
> > > > --
> > > > PHP Development Mailing List <http://www.php.net/>
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > > --
> > > Please always Cc to me when replying to me on the lists.
> > > GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
> > > "Mind if I MFH ?" "What QA did you do on it?" "the usual?" "ah... none :)"
> > >
> >
> >
> > --
> > PHP Development Mailing List <http://www.php.net/>
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> Please always Cc to me when replying to me on the lists.
> GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
> "Mind if I MFH ?" "What QA did you do on it?" "the usual?" "ah... none :)"
>


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php


Reply via email to