File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1908,6 +1908,7 @@ protected function _prepareQuery()
1908
1908
try {
1909
1909
$ stmt = $ this ->mysqli ()->prepare ($ this ->_query );
1910
1910
} catch (Exception $ e ) {
1911
+ //try to reconnect gracefully if the connection was broken since the last query
1911
1912
if ($ this ->mysqli ()->errno === 2006 && $ this ->autoReconnect === true && $ this ->autoReconnectCount === 0 ) {
1912
1913
$ this ->connect ($ this ->defConnectionName );
1913
1914
$ this ->autoReconnectCount ++;
@@ -1921,6 +1922,13 @@ protected function _prepareQuery()
1921
1922
return $ stmt ;
1922
1923
}
1923
1924
1925
+ //if statement is false then the server has been down for awhile and the query is dirty, reconnect and reset
1926
+ //we'll lose one query exection, but the next will be successful
1927
+ if ($ this ->mysqli ()->errno === 2006 && $ this ->autoReconnect === true && $ this ->autoReconnectCount === 0 ) {
1928
+ $ this ->connect ($ this ->defConnectionName );
1929
+ $ this ->autoReconnectCount ++;
1930
+ }
1931
+
1924
1932
$ error = $ this ->mysqli ()->error ;
1925
1933
$ query = $ this ->_query ;
1926
1934
$ errno = $ this ->mysqli ()->errno ;
You can’t perform that action at this time.
0 commit comments