111
This commit is contained in:
+13
-2
@@ -178,8 +178,8 @@ class PDO implements StopHeartbeatCheck
|
||||
/**
|
||||
* @param string $sql
|
||||
* @param array $params
|
||||
* @return array
|
||||
* @throws Exception
|
||||
* @return bool|array|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function fetchColumn(string $sql, array $params = []): bool|null|array
|
||||
{
|
||||
@@ -216,10 +216,21 @@ class PDO implements StopHeartbeatCheck
|
||||
private function queryPrev(string $sql, array $params = []): PDOStatement
|
||||
{
|
||||
$this->_last = time();
|
||||
try {
|
||||
if (($statement = $this->_pdo()->query($sql)) === false) {
|
||||
throw new Exception($this->_pdo()->errorInfo()[1]);
|
||||
}
|
||||
return $this->bindValue($statement, $params);
|
||||
} catch (\Throwable $throwable) {
|
||||
|
||||
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
||||
$this->pdo = null;
|
||||
|
||||
return $this->queryPrev($sql, $params);
|
||||
}
|
||||
|
||||
throw new Exception($throwable->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user