根據官方文檔: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()是否會"發現"呢?
添加回答
舉報
0/150
提交
取消