Re: using mysql_close() = best practice?
| From: | Eric Bauman | Date: | Tue, 27 Oct 2009 06:35:18 +0000 |
| Subject: | Re: using mysql_close() = best practice? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299366@lists.php.net to get a copy of this message | ||
On 24/10/2009 7:36 PM, Kim Madsen wrote:
Hi PHP closes an open db connection when the script is done. I've read somewhere that in PHP6 this behaviour will dissapear, is this true? In that case using mysql_close() would definetly be best practice in all current scripts, to make it portable. A nice solution would probably be adding a end_mysql() or page_end() to all pages and put whatever is needed into that function (mysql_close, mysql_free_result, etc)I can't say with any certainty whether that is true or not - but it certainly seems like it is false. Non-persistent connections are destroyed automatically by the garbage collector when no more references are detected. See http://au2.php.net/manual/en/language.types.resource.php#language.types.resource.self-destruct That said, I believe it to be good practice to close any opened database connection. All my database methods are wrapped in a class, however, so I do this in the destructor.