Re: Is select_db necessary?
| From: | Paul M Foster | Date: | Wed, 12 Aug 2009 03:56:18 +0000 |
| Subject: | Re: Is select_db necessary? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296681@lists.php.net to get a copy of this message | ||
On Tue, Aug 11, 2009 at 08:23:21PM -0700, Allen McCabe wrote:
> I have seen different scripts for working with SQL, and most follow the same
> method with on difference.
>
> Variables are defined (host, password, etc.)
> mysql_connect command
>
> //then, the difference
>
> mysql_select_db command
>
> //back to common
>
> $sql = "SELECT ... "
> $result = mysql_query($ql)
>
> Is the database selection necessary, or is that implied with a SELECT or
> other SQL command?
All major SQL DBMSes can have multiple databases available. A given
database may contain a variety of tables. If you simply start firing SQL
commands at a DBMS, it won't know which database to look in unless you
tell it. By contrast, the connection process in PostgreSQL must include
a database; there is no separate database selection function call.
Paul
--
Paul M. Foster