111
This commit is contained in:
+13
-2
@@ -178,8 +178,8 @@ class PDO implements StopHeartbeatCheck
|
|||||||
/**
|
/**
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @return array
|
* @return bool|array|null
|
||||||
* @throws Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function fetchColumn(string $sql, array $params = []): bool|null|array
|
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
|
private function queryPrev(string $sql, array $params = []): PDOStatement
|
||||||
{
|
{
|
||||||
$this->_last = time();
|
$this->_last = time();
|
||||||
|
try {
|
||||||
if (($statement = $this->_pdo()->query($sql)) === false) {
|
if (($statement = $this->_pdo()->query($sql)) === false) {
|
||||||
throw new Exception($this->_pdo()->errorInfo()[1]);
|
throw new Exception($this->_pdo()->errorInfo()[1]);
|
||||||
}
|
}
|
||||||
return $this->bindValue($statement, $params);
|
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