Re: mysql_query and mysql_db_query

From: Date: Fri, 08 Sep 2000 23:48:24 +0000
Subject: Re: mysql_query and mysql_db_query
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-2758@lists.php.net to get a copy of this message
On Fri, 8 Sep 2000, Kevin Xin Lin wrote: > int mysql_connect ([string hostname [:port] [:/path/to/socket] [, string > username [, string password]]]) > ---- > > This is the syntax of mysql_connect, I don't see any db information. > What DB is in USE when I create a connection to MySQL? What have I > overlooked? Well, I overlooked it too. The sequence is mysql_connect(), mysql_select_db(), then mysql_query(). I overlooked the mysql_select_db() as well. I guess that's because I always use the "default" database which is the same as my username. Also, I tend to use PostgreSQL more often than MySQL, so I forget some of the MySQL steps. Sorry about that! $connect=mysql_connect(...); $database=mysql_select_db("foo",$connect); $result=mysql_query($query,$connect); All queries which use $connect will go against the last mysql_select_db() which specified $connect (or the default db if it wasn't called). I hope I made more sense this time <grin>! John P.S. Does anybody know if doing this is more efficient that using the mysql_db_query() call? I would think that it might since MySQL would be in the correct database already. True?

« previous php.db (#2758) next »