Database Connections
| From: | Bill Arbuckle, Jr. | Date: | Fri, 29 Nov 2002 15:43:05 +0000 |
| Subject: | Database Connections | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-23736@lists.php.net to get a copy of this message | ||
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