Re: [PHP-DB] Multiple instances of mysql_connect() in single PHP document.

[email protected] ("Andy Shellam (Mailing Lists)")
Newsgroups php.db
Message-ID <[email protected]>
Hi,

>
> If the databases are in the same mysql server, then you could qualify
> the table select with the database name and simply re-use the
> connection
>
> select db_name.table_name.field from db_name.table_name [where]

No offence, but if I saw this in an application's source code, I'd run  
a mile.

The negligible overhead of simply making two connections is far better  
in my opinion than having to rewrite each query if the database name  
changed, or to point an application at a copy of the original database  
with a different name for testing.  At least with the dual-connection  
approach, you'd only have to change it once.

Of course in a full application, you'd want the two database  
connection details in a config file, so the databases could even be  
located on separate servers, and you wouldn't need to make a source  
code change to point the application to another database.

Regards,
Andy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.