Reputation: 425
I'm wondering, if mysqli_connect()
does automatically close at the end of the script. I know, that mysql_connect()
does, but I'm speaking about improved mysqli_connect()
.. Also I found answered question, that says it does, but in official documentation it is not written.. So, can I rely on those not official statements? (Or better to ask, it is safe to rely on them?)
Upvotes: 3
Views: 3525
Reputation: 1420
Here's what you should consider. The MySql connection does automatically close when the script terminates. However, if your script does a lot of processing after the data has been retrieved and stored to an array or whatever you store it to, it is safer to close the connection explicitly so you do not face the chance of running out of available connections while the script is busy running the post data retrieval routines. For me, I just explicitly close the connection. It's a habit I've developed and my fingers auto-type the command.
Upvotes: 5