Faqts : Business : Programming : Shopping For You : PHP : Database Backed Sites : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

19 of 21 people (90%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Do I have to close database connections at the end of my scripts?

Jan 26th, 2000 22:33
Nathan Wallace, Mike S. Krischker,


No.

If you are using persistent connections they won't be closed, even if
you do call the close function for your database.  They remain connected
until the Apache process is killed.

If you are not using persistent connections then the connection will be
closed automatically by PHP at the end of script execution.

Having said all that, it's probably good programming technique / style
to close your connections.