Re: Is select_db necessary?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



here a basic background to this question.

all databases are build from various module bases. one module is the
database itself prosessing eg. the sql's another module is the database
connectivity. e.g. mySQL has a ability to connect thru ADO, .NET and an
server via IP.

MySQL supports unlimited databases comtaining tables. so from the point of
the database u have always to selct the database and then to the table.

however, if u study the various Database extensions u will find functions
(eg. mysql_db_query() ) where u point the database in the function call
while others don't (eg. mysql_query() ) on those u have to do a db select
first because the function itself doesn't do it, while mysql_db_connect()
does.

so if we know that now, we are coming to the question, why are database
extensions do have those two types of processing a sql statement?

the answer is: speed ! while those commands with a pointing out the database
do internally a select of the database they do it every time on each call.

if u have a application which does a lot of stuff at the same time other
then just select statement, this comes into consideration. it saves time to
do one select_db first and then 50 just raw sql's to that database.

now after dumping that much stuff on u, it depends on ur design if u need a
select_db first or not.

hope that helps
Ralph
ralph_deffke@xxxxxxxx

"Allen McCabe" <allenmccabe@xxxxxxxxx> wrote in message
news:657acef20908112023y222de6f4q63e64cd1e2785d35@xxxxxxxxxxxxxxxxx
> 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?
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux