Jump to content

Do I need mysqli->close()


cgm225

Recommended Posts

Do I need to close my mysqli object?  I am hearing different things, and this article says I need it...

 

Note that open connections (and similar resources) are automatically destroyed at the end of script execution. However, you should still close or free all connections, result sets and statement handles as soon as they are no longer required. This will help return resources to PHP and MySQL faster.

 

What are the communities thoughts?

Link to comment
https://forums.phpfreaks.com/topic/106962-do-i-need-mysqli-close/
Share on other sites

The close connection is probably going to be one of the last things your script does, so as it's going to happen anyway I don't usually close it myself. However, if I have several queries and large result set early in the script then I will free the results once it's finished with. If it's only finished with at the end of the script then again, I don't bother.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.