diff --git a/Project/php/gateway/GroupGateway.php b/Project/php/gateway/GroupGateway.php index a96f4d3..bc9affc 100755 --- a/Project/php/gateway/GroupGateway.php +++ b/Project/php/gateway/GroupGateway.php @@ -4,6 +4,8 @@ namespace gateway; use PDO; use PDOException; +use config\Connection; +use model\Group; class GroupGateway extends AbsGateway { @@ -27,7 +29,7 @@ class GroupGateway extends AbsGateway } } - public function remove(array $id): void + public function remove(int $id): void { try{ $query = "DELETE FROM Group_ g WHERE g.id=:id "; diff --git a/Project/php/gateway/UserGateway.php b/Project/php/gateway/UserGateway.php index c16baa8..b08fdec 100755 --- a/Project/php/gateway/UserGateway.php +++ b/Project/php/gateway/UserGateway.php @@ -261,4 +261,20 @@ class UserGateway extends AbsGateway throw new Exception($e->getMessage()); } } + + public function findUsersByGroup(int $id): array { + try { + $query = "SELECT * FROM User_ WHERE groupID=:group"; + $args = array(':group' => array($id, PDO::PARAM_INT)); + $this->con->executeQuery($query, $args); + $results = $this->con->getResults(); + $tab = array(); + foreach ($results as $row) + $tab[] = new User($row['id'], $row['password'], $row['email'], $row['name'], $row['surname'], $row['nickname'], $row['image'], $row['extraTime'], $row['groupID'], $this->getRoles($row['id'])); + return $tab; + } + catch(PDOException $e ){ + throw new Exception($e->getMessage()); + } + } } \ No newline at end of file diff --git a/Project/php/gateway/VocabularyGateway.php b/Project/php/gateway/VocabularyGateway.php index 1120b97..4aee47e 100755 --- a/Project/php/gateway/VocabularyGateway.php +++ b/Project/php/gateway/VocabularyGateway.php @@ -28,7 +28,7 @@ class VocabularyGateway extends AbsGateway } } - public function remove(array $id): void + public function remove(int $id): void { try{ $query = "DELETE FROM Vocabulary v WHERE v.id=:id ";