Reputation: 20012
In PHP + MySQL
This is:
$conn = mysql_connect("server","user","pass");
mysql_select_db("datbasename");
what we do to open a connection.
And this is:
mysql_close($conn);
what we do to close the connection.
Upvotes: 3
Views: 2053
Reputation: 21957
With mysql_connect
connection will close, when script is ended.
mysql_pconnect
doesn't close connection.
If you work with more then 1 mysql servers, is necessery to control your closing connections, or create some persistance.
Upvotes: 2
Reputation: 134167
From the PHP documentation for mysql_close:
Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution. See also freeing resources.
Upvotes: 6
Reputation: 12078
In a small application nothing at all. PHP is nice and cleans up memory/closes connections upon scripts execution completion. If you are concerned about resources and utilization then I suggest closing your connections when you are finished using them.
Upvotes: 1