Created
February 18, 2014 10:40
-
-
Save youhey/9068421 to your computer and use it in GitHub Desktop.
MySQLのサーバタイムアウトetc..を検知
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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