Skip to content

Instantly share code, notes, and snippets.

@youhey
Created February 18, 2014 10:40
Show Gist options
  • Save youhey/9068421 to your computer and use it in GitHub Desktop.
Save youhey/9068421 to your computer and use it in GitHub Desktop.
MySQLのサーバタイムアウトetc..を検知
define('MYSQL_ERROR_SERVER_GONE_ERROR', '2006');
define('RESULT_DB_GONE_AWAY', '2006');
try {
....
} catch (PDOException $e) {
if ($e->errorInfo[1] === MYSQL_ERROR_SERVER_GONE_ERROR) {
// リトライ情報とか
$response = array('status' => RESULT_DB_GONE_AWAY);
$jsonText = json_encode($response);
echo $jsonText;
exit(1);
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment