Re: [PHP] General Mysql Connect



On Wed, 2008-10-29 at 20:12 -0500, Micah Gersten wrote:
Waynn Lue wrote:
With MySQL, you can change the DB from query to query with
mysql_select_db. The alternative as I stated in my last post is to use
the fully qualified table name (database.table) in your query. MySQL
doesn't care which DB you have open if you do that. In both of these
cases, the same connection is used.



That brings me back to the original point, is there a performance decrease
to continually calling mysql_select_db? And shouldn't connections that are
being made during the processing of a php script (which runs for no more
than two seconds) be lasting at least until the end of the script, instead
of getting errors like "Lost connection to server"?


The only overhead of constantly using mysql_select_db is 2 function
calls to make a query instead of just using the database name in the
query. However, this should not be that expensive.
Yes, connections should be available for the whole script if you don't
destroy them.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



I'm just thinking about how other languages work with regards to
databases. I'm pretty sure that opening extra database connections,
regardless of whether they are on the same server or not, you will incur
extra opcodes. ColdFusion does it with MSSQL, and I'm guessing that PHP
on Windows using MSSQL or MySQL is going to be fairly the same. Linux
could be different, but why would the developers of the connection
driver write totally different code for both OS's?


Ash
www.ashleysheridan.co.uk

.



Relevant Pages

  • Re: Ada DB bindings and APQ
    ... >>I didn't like the use of handles for database objects. ... > will ensure that the connection will not go away until at least one query ... > things which can be made with a connection. ... That is different to ODBC. ...
    (comp.lang.ada)
  • Disconnect/Reconnect (was: phpMyAdmin)
    ... In MySQL ist es so, daß die Connection einen besonderen Kontext oder Scope darstellt. ... Ein Disconnect entspricht einen ROLLBACK. ... Das gilt für viele grafische Clients - viele von denen machen nach dem Absenden der Query und dem Lesen des Resultsets einen Disconnect und verbinden sich für die folgende Query neu, darunter auch der MySQL Query Browser. ...
    (de.comp.datenbanken.mysql)
  • Re: hitting the limits
    ... relatively straight forward MySql database. ... 10K visitors a month and an 80Mb database are nothing. ... heavily loaded server. ... But the connection will hang around until the garbage ...
    (comp.lang.php)
  • Re: VFP8 & MySQL
    ... > VFP functions like NVL to a MySQL one, definitely it made the switch very ... > About your connection problem, I have mine setup as default for 100 ... As for the server, we left it ... The server crashed and corrupted the database. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: VFP8 & MySQL
    ... Main Location and 3 branches (these are remotely accessing MySQL at the main ... About your connection problem, I have mine setup as default for 100 ... As for the server, we left it alone. ... The server crashed and corrupted the database. ...
    (microsoft.public.fox.programmer.exchange)