Skip to content

Commit

Permalink
Update Database.php
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisnikoy committed May 2, 2024
1 parent 9e78e21 commit f3764e7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()];
}
}

Expand Down

0 comments on commit f3764e7

Please sign in to comment.