title: mysql server has gone away in PDO
body: <p>I am running my php script and getting an intermittent issue:</p>
  
  <p>PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query'</p>
  
  <p>Is it possible to ping mysql in PDO if such error occurs?</p>
  
  <p>I just want to bring this in your notice that my PDO connection is not persistent. I am connecting PDO in loop. I suppose every time a new connection will open up in loop. If this is so, then why mysql is losing connection? Or it may possible that if a PDO connection already exists then it gives the existing pdo object. but if such error occurs, it should try to reconnect and give the new connection instead of error.</p>
  
  <p>Any possible solution to avoid the error?</p>