qqq
This commit is contained in:
+25
-12
@@ -85,11 +85,10 @@ class Command extends Component
|
|||||||
$prepare->execute($this->params);
|
$prepare->execute($this->params);
|
||||||
return $prepare->fetchAll(PDO::FETCH_ASSOC);
|
return $prepare->fetchAll(PDO::FETCH_ASSOC);
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
$result = $this->error($throwable);
|
if ($this->isRefresh($throwable)) {
|
||||||
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
|
||||||
return $this->all();
|
return $this->all();
|
||||||
}
|
}
|
||||||
return $result;
|
return $this->error($throwable);
|
||||||
} finally {
|
} finally {
|
||||||
$this->connection->release($client);
|
$this->connection->release($client);
|
||||||
}
|
}
|
||||||
@@ -109,11 +108,10 @@ class Command extends Component
|
|||||||
$prepare->execute($this->params);
|
$prepare->execute($this->params);
|
||||||
return $prepare->fetch(PDO::FETCH_ASSOC);
|
return $prepare->fetch(PDO::FETCH_ASSOC);
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
$result = $this->error($throwable);
|
if ($this->isRefresh($throwable)) {
|
||||||
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
|
||||||
return $this->one();
|
return $this->one();
|
||||||
}
|
}
|
||||||
return $result;
|
return $this->error($throwable);
|
||||||
} finally {
|
} finally {
|
||||||
$this->connection->release($client);
|
$this->connection->release($client);
|
||||||
}
|
}
|
||||||
@@ -133,11 +131,10 @@ class Command extends Component
|
|||||||
$prepare->execute($this->params);
|
$prepare->execute($this->params);
|
||||||
return $prepare->fetchColumn(PDO::FETCH_ASSOC);
|
return $prepare->fetchColumn(PDO::FETCH_ASSOC);
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
$result = $this->error($throwable);
|
if ($this->isRefresh($throwable)) {
|
||||||
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
|
||||||
return $this->fetchColumn();
|
return $this->fetchColumn();
|
||||||
}
|
}
|
||||||
return $result;
|
return $this->error($throwable);
|
||||||
} finally {
|
} finally {
|
||||||
$this->connection->release($client);
|
$this->connection->release($client);
|
||||||
}
|
}
|
||||||
@@ -176,16 +173,32 @@ class Command extends Component
|
|||||||
}
|
}
|
||||||
return $result == 0 ? true : (int)$result;
|
return $result == 0 ? true : (int)$result;
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
$result = $this->error($throwable);
|
if ($this->isRefresh($throwable)) {
|
||||||
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
|
||||||
return $this->_execute();
|
return $this->_execute();
|
||||||
}
|
}
|
||||||
return $result;
|
return $this->error($throwable);
|
||||||
} finally {
|
} finally {
|
||||||
$this->connection->release($client);
|
$this->connection->release($client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Throwable $throwable
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isRefresh(Throwable $throwable): bool
|
||||||
|
{
|
||||||
|
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (str_contains($throwable->getMessage(), 'Send of 14 bytes failed with errno=32 Broken pipe')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Throwable $throwable
|
* @param Throwable $throwable
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|||||||
Reference in New Issue
Block a user