Database Connections

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

 



I have a general question concerning databases in php.  More specifically,
what is the general consensus on maintaining a connection.  Some of this is
more than likely my ignorance.

My connection stuff goes something like this ...


$db = mysql_connect("localhost", "stuff", "pw") or die("Could Not Connect");
mysql_select_db("stuff",$db) or die("Could Not Select Database");

<<< Other Code Here >>>

mysql_free_result($result);
mysql_close($db);


It seems very inefficient to open and close a database with each different
page or call to that database.  My question is ... Is there a better way
and, if so, what is it?  I guess I do not quite understand just how long a
connection is maintained.  I hate to write code that doesn't clean up after
itself.  Any suggestions are appreciate.  TIA

Bill


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux