在设置了MYSQL_OPT_RECONNECT之后,mysql_ping是否还有必要?
PHP中文网
PHP中文网 2017-04-17 11:03:17
0
2
428

根据官方文档:

Checks whether the connection to the server is working. If the connection has gone down and auto-reconnect is enabled an attempt to reconnect is made. If the connection is down and auto-reconnect is disabled, mysql_ping() returns an error.

也就是说,如果 MYSQL_OPT_RECONNECT 没有被设置为 1(开启),那么mysql_ping()不会完成自动重连,只是简单返回一个error。

那么如果已经开启这个选项了呢?官方文档又说了:

MYSQL_OPT_RECONNECT (argument type: my_bool *)
Enable or disable automatic reconnection to the server if the connection is found to have been lost.

也就是说,如果发现连接断开,那么会启动自动重连功能。

现在问题是:连接断开这事儿是啥时候被发现的呢?

根据官方文档mysql_ping()肯定是会发现,那mysql_query()是否会"发现"呢?

PHP中文网
PHP中文网

认证0级讲师

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!