This commit is contained in:
2023-04-02 19:57:48 +08:00
parent f554b4c81e
commit 67fdee8fd9
+12 -20
View File
@@ -69,21 +69,19 @@ class Command extends Component
[$pdo, $statement] = $this->search(); [$pdo, $statement] = $this->search();
$statement->execute($this->params); $statement->execute($this->params);
$data = $statement->fetchAll(PDO::FETCH_ASSOC);
$this->db->release($pdo); return $statement->fetchAll(PDO::FETCH_ASSOC);
return $data;
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
$this->db->restore(); $this->db->restore();
return $this->one(); return $this->one();
} }
return $this->printErrorMessage($throwable);
} finally {
if (isset($pdo)) { if (isset($pdo)) {
$this->db->release($pdo); $this->db->release($pdo);
} }
return $this->printErrorMessage($throwable);
} }
} }
@@ -97,21 +95,19 @@ class Command extends Component
[$pdo, $statement] = $this->search(); [$pdo, $statement] = $this->search();
$statement->execute($this->params); $statement->execute($this->params);
$data = $statement->fetch(PDO::FETCH_ASSOC);
$this->db->release($pdo); return $statement->fetch(PDO::FETCH_ASSOC);
return $data;
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
$this->db->restore(); $this->db->restore();
return $this->one(); return $this->one();
} }
return $this->printErrorMessage($throwable);
} finally {
if (isset($pdo)) { if (isset($pdo)) {
$this->db->release($pdo); $this->db->release($pdo);
} }
return $this->printErrorMessage($throwable);
} }
} }
@@ -125,21 +121,19 @@ class Command extends Component
[$pdo, $statement] = $this->search(); [$pdo, $statement] = $this->search();
$statement->execute($this->params); $statement->execute($this->params);
$data = $statement->fetchColumn(PDO::FETCH_ASSOC);
$this->db->release($pdo); return $statement->fetchColumn(PDO::FETCH_ASSOC);
return $data;
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
$this->db->restore(); $this->db->restore();
return $this->fetchColumn(); return $this->fetchColumn();
} }
return $this->printErrorMessage($throwable);
} finally {
if (isset($pdo)) { if (isset($pdo)) {
$this->db->release($pdo); $this->db->release($pdo);
} }
return $this->printErrorMessage($throwable);
} }
} }
@@ -153,21 +147,19 @@ class Command extends Component
[$pdo, $statement] = $this->search(); [$pdo, $statement] = $this->search();
$statement->execute($this->params); $statement->execute($this->params);
$data = $statement->rowCount();
$this->db->release($pdo); return $statement->rowCount();
return $data;
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) { if (str_contains($throwable->getMessage(), 'MySQL server has gone away')) {
$this->db->restore(); $this->db->restore();
return $this->rowCount(); return $this->rowCount();
} }
return $this->printErrorMessage($throwable);
} finally {
if (isset($pdo)) { if (isset($pdo)) {
$this->db->release($pdo); $this->db->release($pdo);
} }
return $this->printErrorMessage($throwable);
} }
} }