changed return to bool on update and delete

This commit is contained in:
tracer 2022-10-28 17:00:53 +02:00
parent 24c8a3d9d7
commit e2bf38299b

View File

@ -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());
}