This commit is contained in:
2023-08-24 11:55:43 +08:00
parent 8b35064395
commit e06c04a5bb
+12 -4
View File
@@ -77,8 +77,8 @@ class Command extends Component
*/
public function all(): bool|array
{
$client = $this->connection->getConnection();
try {
$client = $this->connection->getConnection();
if (($prepare = $client->prepare($this->sql)) === false) {
throw new Exception($client->errorInfo()[1]);
}
@@ -91,9 +91,11 @@ class Command extends Component
}
return $result;
} finally {
if (isset($client)) {
$this->connection->release($client);
}
}
}
/**
* @return bool|array|null
@@ -101,8 +103,8 @@ class Command extends Component
*/
public function one(): null|bool|array
{
$client = $this->connection->getConnection();
try {
$client = $this->connection->getConnection();
if (($prepare = $client->prepare($this->sql)) === false) {
throw new Exception($client->errorInfo()[1]);
}
@@ -115,9 +117,11 @@ class Command extends Component
}
return $result;
} finally {
if (isset($client)) {
$this->connection->release($client);
}
}
}
/**
* @return mixed
@@ -125,8 +129,8 @@ class Command extends Component
*/
public function fetchColumn(): mixed
{
$client = $this->connection->getConnection();
try {
$client = $this->connection->getConnection();
if (($prepare = $client->prepare($this->sql)) === false) {
throw new Exception($client->errorInfo()[1]);
}
@@ -139,9 +143,11 @@ class Command extends Component
}
return $result;
} finally {
if (isset($client)) {
$this->connection->release($client);
}
}
}
/**
@@ -161,8 +167,8 @@ class Command extends Component
*/
private function _execute(): bool|int
{
$client = $this->connection->getConnection();
try {
$client = $this->connection->getConnection();
if (($prepare = $client->prepare($this->sql)) === false) {
throw new Exception($client->errorInfo()[1]);
}
@@ -182,9 +188,11 @@ class Command extends Component
}
return $result;
} finally {
if (isset($client)) {
$this->connection->release($client);
}
}
}
/**
* @param Throwable $throwable