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

根据官方文档:

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學習者快速成長!