什么是在PHP中关闭mysql连接的最佳位置? [英] what is best location for close mysql connection in php ?

查看:201
本文介绍了什么是在PHP中关闭mysql连接的最佳位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

i有一些与mysql数据库兼容的php函数



什么是关闭数据库连接的最佳位置?< br $> b $ b

请帮帮我



非常感谢

hi all
i have a some php function that work with mysql database

what is a best location for close database connection ?

please help me

thanks a lot

推荐答案

问题适用于所有技术,例如.NET,PHP等。当执行任何数据库命令/查询需要时,您应该打开数据库连接,在获得结果后,您应该关闭该连接。只有问题区域可以找到连接结果集提取问题。在.NET中像datareader。在完成读取datareader对象之前,无法关闭连接。如果在PHP中有相同类型的返回对象,那么在完成后读取该对象然后关闭它。始终需要记住数据库打开连接时间应尽可能短。
The question is true for all technology for example .NET, PHP etc. When required for execute any database command/query then you should open database connection and after getting result you should close that connection. Only problem area you can find that is connected resultset fetching issue. In .NET like datareader. You can not close connection until you finish to read datareader object. If same type of return object there in PHP then after finish to read that object then you close it. Always need to remember that database open connection time should as shorter as possible.


每次需要时打开和关闭连接都是首选。
It is preferred to Open and Close the Connection each time you required.


这篇关于什么是在PHP中关闭mysql连接的最佳位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆