From f3764e7a32bd99892ed316be930246dbbb16594e Mon Sep 17 00:00:00 2001 From: Jannis Nikou Date: Thu, 2 May 2024 14:12:23 -0700 Subject: [PATCH] Update Database.php --- src/Database.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Database.php b/src/Database.php index 9623a09..002b359 100644 --- a/src/Database.php +++ b/src/Database.php @@ -61,11 +61,13 @@ public function query(string $sql): array { $this->statement->execute(); - if (strtoupper(substr(ltrim($sql), 0, 6)) === "SELECT") { + $substr = strtoupper(substr(ltrim($sql), 0, 6)); + + if ($substr == "INSERT" || $substr == "UPDATE" || $substr == "DELETE") { + return [$this->statement->rowCount()]; + }else { $this->result = $this->statement->fetchAll(\PDO::FETCH_OBJ); return $this->result; - } else { - return [$this->statement->rowCount()]; } }