From 24db1bd83d151366be766629301b20ef9c7f1cdd Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 13 Sep 2024 15:36:45 +0000 Subject: [PATCH] Made IDbStatement::execute return number of affected rows. --- VERSION | 2 +- src/Data/IDbStatement.php | 6 ++++-- src/Data/MariaDB/MariaDBStatement.php | 6 ++++-- src/Data/NullDb/NullDbStatement.php | 6 ++++-- src/Data/SQLite/SQLiteStatement.php | 6 ++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index ca0dfdc..719c569 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2408.182001 +0.2408.401736 diff --git a/src/Data/IDbStatement.php b/src/Data/IDbStatement.php index 1322936..6d4692b 100644 --- a/src/Data/IDbStatement.php +++ b/src/Data/IDbStatement.php @@ -1,7 +1,7 @@ statement->insert_id; } - public function execute(): void { + public function execute(): int|string { $args = ['']; foreach($this->params as $key => $param) { @@ -154,6 +154,8 @@ class MariaDBStatement implements IDbStatement { if(!$this->statement->execute()) throw new RuntimeException($this->getLastErrorString(), $this->getLastErrorCode()); + + return $this->statement->affected_rows; } public function reset(): void { diff --git a/src/Data/NullDb/NullDbStatement.php b/src/Data/NullDb/NullDbStatement.php index a6af889..1c82859 100644 --- a/src/Data/NullDb/NullDbStatement.php +++ b/src/Data/NullDb/NullDbStatement.php @@ -1,7 +1,7 @@ connection->getLastInsertId(); } - public function execute(): void { + public function execute(): int|string { $result = $this->statement->execute(); if($result === false) throw new RuntimeException((string)$this->connection->getLastErrorString(), $this->connection->getLastErrorCode()); $this->result = $result; + + return $this->connection->getAffectedRows(); } public function reset(): void {