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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.