|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-11-20 12:34 UTC] bate@php.net
[2001-11-20 12:48 UTC] bate@php.net
[2001-11-20 12:57 UTC] mfischer@php.net
[2001-11-20 12:57 UTC] mfischer@php.net
[2001-11-20 13:00 UTC] derick@php.net
[2001-11-20 15:01 UTC] lenar at vision dot ee
[2001-11-22 03:26 UTC] mfischer@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 06:00:01 2025 UTC |
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.