From f8b04c7ab3b5596a5f228f7a95bf85b4b7973402 Mon Sep 17 00:00:00 2001 From: Anthony RICHARD Date: Wed, 25 Oct 2023 10:16:35 +0200 Subject: [PATCH] Classe connection + classe group --- Project/php/config/Connection.php | 34 ++++++++++++++++ Project/php/model/Group.php | 68 +++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100755 Project/php/config/Connection.php create mode 100755 Project/php/model/Group.php diff --git a/Project/php/config/Connection.php b/Project/php/config/Connection.php new file mode 100755 index 0000000..4588c10 --- /dev/null +++ b/Project/php/config/Connection.php @@ -0,0 +1,34 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + + +/** * @param string $query + * @param array $parameters * + * @return bool Returns `true` on success, `false` otherwise +*/ + + public function executeQuery(string $query, array $parameters = []) : bool{ + $this->stmt = parent::prepare($query); + foreach ($parameters as $name => $value) { + $this->stmt->bindValue($name, $value[0], $value[1]); + } + + return $this->stmt->execute(); +} + + public function getResults() : array { + return $this->stmt->fetchall(); + + } +} + +?> diff --git a/Project/php/model/Group.php b/Project/php/model/Group.php new file mode 100755 index 0000000..090da4e --- /dev/null +++ b/Project/php/model/Group.php @@ -0,0 +1,68 @@ +id = $id; + $this->num = $num; + $this->year = $year; + $this->sector = $sector; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @return int + */ + public function getNum(): int + { + return $this->num; + } + + /** + * @return int + */ + public function getYear(): int + { + return $this->year; + } + + /** + * @return string + */ + public function getSector(): string + { + return $this->sector; + } + + public function addUser(Users $user){ + $this->students.add($user); + } + + public function removeUser(Users $user){ + $this->students . remove($user); + } +} \ No newline at end of file