dsms21398
dsms21398
2015-01-14 22:43
浏览 284
已采纳

mysqli_connect会在脚本结束时自动关闭吗?

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?)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanbipu1720
    duanbipu1720 2015-01-14 22:58
    已采纳

    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.

    点赞 评论

相关推荐