I have a nice function called lnk() that I have been using for a very long time that connects to MySQL. Recently I decided to add to it the mysqli_ping call to check the connection and reconnect if need be as I was experiencing issues with a daemon (running 24/7) that kept losing connection to MySQL after long periods of inactivity.
After implementation I started having problems with multi-queries. Connection to MySQL is lost at the moment the ping is sent if it is sent after mysqli_multi_query unless mysqli_store_result comes before the ping.
$mq = mysqli_multi_query(lnk(), "SHOW PROCESSLIST;");
mysqli_next_result(lnk());
$result = mysqli_store_result(lnk());
while($row = mysqli_fetch_row($result)) {
print_r($row);
}
Any ideas why this is happening?
Please do not suggest to add a variable to the library to ignore connection check in those cases. I have already thought of that and it's not good enough. I need to know exactly why is this happening and what the ping does to my connection in this case.