作者 邓超

x

... ... @@ -66,7 +66,10 @@ class DbPool {
*/
public function connect(){
$this->lastTimer = time();
// try {
$tryNum = 0;
DBPOOLCONNECTFOR:
try {
$this->client = new \PDO(
'mysql:charset=utf8mb4;dbname='.DB_DATABASE.';host='.DB_HOST.';port='.DB_PORT,
DB_USER,
... ... @@ -77,9 +80,18 @@ class DbPool {
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
]
);
// }catch (\Throwable $e){
// logs($e->getMessage().$e->getTraceAsString());
// }
}catch (\Throwable $e){
// 重新链接3次
if($tryNum < 3){
$tryNum++;
goto DBPOOLCONNECTFOR;
}
logs($e->getMessage().$e->getTraceAsString());
}
}
... ...