Bug #14137 Updated: Request additional flag for mysql_connect
| From: | bate@php.net | Date: | Tue, 20 Nov 2001 17:48:50 +0000 |
| Subject: | Bug #14137 Updated: Request additional flag for mysql_connect | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-71104@lists.php.net to get a copy of this message | ||
ID: 14137
Updated by: bate
Reported By: lenar@vision.ee
Status: Bogus
Bug Type: MySQL related
Operating System: Debian/Linux
PHP Version: 4.0CVS-2001-11-20
New Comment:
Ups sorry wrong links. :)
http://www.php.net/manual/en/ref.mysql.php
http://www.php.net/manual/en/function.mysql-db-query.php
--Marco
Note: This function has been deprecated since PHP 4.0.6. Do not use this function. Use
mysql_select_db() and mysql_query() instead.
read the User comment's
Previous Comments:
------------------------------------------------------------------------
[2001-11-20 12:34:58] bate@php.net
bool mysql_select_db (string database_name, resource [link_identifier])
http://www.php.net/manual/en/function.mysql-select-db.php
--Marco
P.S. Maybe you upgrade your system or you learn to read the manual pages.
------------------------------------------------------------------------
[2001-11-20 04:17:22] lenar@vision.ee
Manual states:
If a second call is made to mysql_connect() with the same
arguments, no new link will be established, but instead,
the link identifier of the already opened link will be
returned.
Most of the times this is good. With one exception.
Let's describe this situation.
I have 2 databases. I have 1 user account for mysql.
I need to use both of those databases simultaneously in my
script.
Now i do:
$id1 = mysql_connect($host, $username, $password);
mysql_select_db("db1", $id1);
$id2 = mysql_connect($host, $username, $password);
mysql_select_db("db2", $id2);
And now I think why so many errors :(
Second call to mysql_connect() returns same resource, so
my active database is db2 now. But I want to use data from
two databases at once. So this 'reuse' feature is bad for
me.
Now, I use a wrapper class so I could issue an
mysql_select_db() every time I do a query. But I think
this is not a wise thing to do.
So I ask: Shouldn't be there a flag with meaning like 'do
not try to reuse exitsing connection'. Or may be just an
additional string argument 'database' which when specified
automagically selects that database and subsequent calls to
mysql_connect() take that value into account when deciding
to return or not to return existing resource.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14137&edit=1