ID: 14137
Updated by: mfischer
Reported By: [EMAIL PROTECTED]
Old Status: Bogus
Status: Open
Bug Type: MySQL related
Operating System: Debian/Linux
PHP Version: 4.0CVS-2001-11-20
New Comment:

Not so fast ..

This is definitely a problem when you try to connect to MySQL twice with the same 
incredentials (host,user,pass) you don't get the old link back and thus changing the 
database on one link obviously changes it on the other too ...

Should be a Feature Request, note sure.

A workaround is to create another user.

Reopened.

Previous Comments:
------------------------------------------------------------------------

[2001-11-20 12:48:50] [EMAIL PROTECTED]

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


------------------------------------------------------------------------

[2001-11-20 12:34:58] [EMAIL PROTECTED]

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] [EMAIL PROTECTED]

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


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to