This commit is contained in:
2023-12-13 17:02:29 +08:00
parent 9a670f626e
commit 79b7bb432f
+2 -7
View File
@@ -14,7 +14,6 @@ use Exception;
use Kiri\Abstracts\Component; use Kiri\Abstracts\Component;
use Kiri\Di\Container; use Kiri\Di\Container;
use PDO; use PDO;
use PDOStatement;
use Throwable; use Throwable;
/** /**
@@ -28,7 +27,6 @@ class Command extends Component
public ?string $sql = ''; public ?string $sql = '';
public array $params = []; public array $params = [];
/** /**
* @param array $params * @param array $params
* @throws * @throws
@@ -123,13 +121,10 @@ class Command extends Component
throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $client->errorInfo()[2]); throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $client->errorInfo()[2]);
} }
$prepare->execute($this->params); $result = $method == 'rowCount' ? $prepare->rowCount() : $prepare->{$method}(PDO::FETCH_ASSOC);
$prepare->closeCursor(); $prepare->closeCursor();
if ($method == 'rowCount') { return $result;
return $prepare->rowCount();
}
return $prepare->{$method}(PDO::FETCH_ASSOC);
} catch (Throwable $throwable) { } catch (Throwable $throwable) {
if ($this->isRefresh($throwable)) { if ($this->isRefresh($throwable)) {
return $this->search($method); return $this->search($method);