RE: Best Practices? [PHP-DB] Queries from two databases

From: Date: Thu, 19 Jul 2007 15:11:41 +0000
Subject: RE: Best Practices? [PHP-DB] Queries from two databases
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-43807@lists.php.net to get a copy of this message
From: Joaquín <javalpi@gmail.com> I need query tables that are in two different databases mysql_select_db("DB1", $conn_1); mysql_select_db("DB2", $conn_2); $result_t1 = mysql_query("SELECT * FROM Table1inDB1",$conn_1); $row_t1 = mysql_fetch_assoc($result_t1); $result_t2 = mysql_query("SELECT * FROM Table2inDB2",$conn_2); $row_t2 = mysql_fetch_assoc($result_t2);
Although Joaquín said his issue is [Fixed], I write these queries as: SELECT * FROM DB1.TableInDB1 SELECT * FROM DB2.TableInDB2 (with and without link_identifiers I believe), so I was wondering about best practices. I can see if you already have code written without the DB in the FROM clause, it could be easier to have multiple links. I haven't really used multiple links, but I ran into issues with multiple databases and consistently setting the correct DB, so now if I know I'll be using multiple DB's, I just write the query with the DB in the FROM clause. (A prior fix was to select the DB before each query. But if it was already selected, it seemed like a waste {according to my "by inspection" profiler}. So I started using the DB in the FROM clause.) Are there any recommendations regarding best practices between: 1) using multiple links and table.field (or table) notation versus 2) database.table.field (or database.table) notation? _________________________________________________________________ Local listings, incredible imagery, and driving directions - all in one place! http://maps.live.com/?wip=69&FORM=MGAC01

« previous php.db (#43807) next »