On Saturday 24 August 2002 15:42, Zeev Suraski wrote: > 8 months too late I noticed that someone has deprecated mysql_db_query(). > > Can anybody explain the reasoning for deprecating it? Other than breaking > tons of sites, I don't see any advantage to it. Even for efficiency > junkies, mysql_db_query() is significantly more efficient than the > mysql_select_db() and mysql_query() combo, if you only make a single query > on a page (which accounts for a great deal of the pages in my experience).
Ok, here is 1 reason: DB1 and DB2 both have tables user and test $db = mysql_connect (..... // select backup db mysql_select_db("DB2", $db); .... // Write something in our production db mysql_db_query ("DB1", "insert into test ... "); // empty test table from backup db mysql_query ("delete from test"); And what happened? mysql_db_query switched the current db from db2 to db1 and you deleted all the data in the test table from your production db! Cheers! The solution is to use mysql_query instead: // Write something into our production db mysql_query ("insert into DB1.test ....") // empty test table from backup db mysql_query ("delete from DB2.test") or "delete from test" Cause the mysql-clientlib has no functionallity to determine the current selected database ist not possible to set the previous selected(default) db via mysql_select_db() back. The db field in the mysql structure only contains a valid db-entry, when you selected the db with mysql_select_db, not when you used mysql_query("USE DB"); Georg -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php