RE: [PHP-DEV] Bug #729: mysql_connect reuses connection ids
| From: | Dave Walton | Date: | Wed, 09 Sep 1998 23:20:46 +0000 |
| Subject: | RE: [PHP-DEV] Bug #729: mysql_connect reuses connection ids | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-893@lists.php.net to get a copy of this message | ||
On 9 Sep 98, at 16:37, Shane Caraveo wrote:
> > From: Zeev Suraski [mailto:bourbon@netvision.net.il]
> >
> > It causes problems since you can't 'black-box' any code portion that
> > connects to an SQL server and disconnects from it, since
> > disconnecting may
> > close other instances of that same link, outside the black-boxed code.
Whoa... Zeev and I agree on this one! ;)
> Hmm, didn't entirly think of that, but it's still easy enough to work around
> in userland.
I'm not sure "easy" is the word I'd use. If it's just a matter of not
closing connections, sure. But my 'black-box' function uses a
different database than the rest of the page. Both
mysql_select_db() and mysql_db_query() change the database
that the connection is using, causing all subsequent queries to fail.
I was really quite astonished that a function with only locally-
scoped variables could have global side-effects! The only work-
around I'm aware of is to have any script that calls that function use
mysql_select_db() afterwards. So much for the black box..
> Anyway, just to do away with it alltogether, maybe an optional
> parameter that specifies to use a new connection then. so
> mysql_connect(db,user,password,opt) opt=true=new connection
That looks like a good solution.
Dave
----------------------------------------------------------------------
Dave Walton
Webmaster, Postmaster Nordic Entertainment Worldwide
walton@nordicdms.com http://www.nordicdms.com
----------------------------------------------------------------------
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net