From e2bf38299bda3f0ee4dd65d06da76f987652b82b Mon Sep 17 00:00:00 2001 From: tracer Date: Fri, 28 Oct 2022 17:00:53 +0200 Subject: [PATCH] changed return to bool on update and delete --- src/Repository/UserRepository.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 69d36ba..fb9e37e 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -137,7 +137,7 @@ class UserRepository } - public function update(User $user): bool|int + public function update(User $user): bool { $id = $user->getId(); $nick = $user->getNick(); @@ -169,9 +169,7 @@ class UserRepository $statement->bindParam(param: 'first', var: $first); $statement->bindParam(param: 'last', var: $last); $statement->bindParam(param: 'is_admin', var: $isAdmin); - $statement->execute(); - - return $statement->rowCount(); + return $statement->execute(); } catch (PDOException $e) { echo $e->getMessage(); return false; @@ -179,7 +177,7 @@ class UserRepository } - public function delete(User $user): int + public function delete(User $user): bool { $sql = " DELETE FROM " . DatabaseConnection::TABLE_USERS . " @@ -189,9 +187,7 @@ class UserRepository $statement = $this->databaseConnection->getConnection()->prepare(query: $sql); $id = $user->getId(); $statement->bindParam(param: 'id', var: $id); - $statement->execute(); - - return $statement->rowCount(); + return $statement->execute(); } catch (PDOException $e) { exit($e->getMessage()); }