This commit is contained in:
2023-08-29 22:13:37 +08:00
parent 5158b709bd
commit 91edb08238
2 changed files with 17 additions and 52 deletions
+8 -8
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]);
}
@@ -90,7 +90,7 @@ class Command extends Component
}
return $this->error($throwable);
} finally {
$this->connection->release($client);
$this->connection->release($client ?? null);
}
}
@@ -100,8 +100,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]);
}
@@ -113,7 +113,7 @@ class Command extends Component
}
return $this->error($throwable);
} finally {
$this->connection->release($client);
$this->connection->release($client ?? null);
}
}
@@ -123,8 +123,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]);
}
@@ -136,7 +136,7 @@ class Command extends Component
}
return $this->error($throwable);
} finally {
$this->connection->release($client);
$this->connection->release($client ?? null);
}
}
@@ -158,8 +158,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]);
}
@@ -178,7 +178,7 @@ class Command extends Component
}
return $this->error($throwable);
} finally {
$this->connection->release($client);
$this->connection->release($client ?? null);
}
}