From ca49ecd74e57b9a7568cc93491de7c7333e5414a Mon Sep 17 00:00:00 2001 From: Kevin MONDEJAR Date: Wed, 23 Oct 2024 15:15:15 +0200 Subject: [PATCH] Supprimer 'models/sourceGateway.php' --- models/sourceGateway.php | 116 --------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 models/sourceGateway.php diff --git a/models/sourceGateway.php b/models/sourceGateway.php deleted file mode 100644 index 8389526..0000000 --- a/models/sourceGateway.php +++ /dev/null @@ -1,116 +0,0 @@ - co = $co; - } - - public function create(sourceEntity $s) : bool - { - $query = " - INSERT INTO Source - VALUES(:id_source, :title, :date) - "; - - return $this -> co -> executeQuery($query, [ - "id_source" => array($s->getIdSource(), PDO::PARAM_INT), - "title" => array($s->getTitle(), PDO::PARAM_STR), - "date" => array($s->getDate(), PDO::PARAM_STR) - ]); - } - - public function findById(int $id) : ?sourceEntity - { - $query = "SELECT * FROM Source WHERE id_source = :id"; - - $this -> co -> executeQuery($query, array("id_source" => array($id, PDO::PARAM_INT))); - $res = $this -> co -> getResults(); - - if ($res) - return new sourceEntity( - $res["id_source"], - $res["title"], - $res["date"] - ); - return null; - } - - public function findByTitle(string $t) : ?sourceEntity - { - $query = "SELECT * FROM Source WHERE title = :t"; - - $this -> co -> executeQuery($query, ["title" => array($t, PDO::PARAM_STR)]); - $res = $this -> co -> getResults(); - - if ($res) - return new sourceEntity( - $res["id_source"], - $res["title"], - $res["date"] - ); - return null; - } - - public function findByDate(string $d) : ?sourceEntity - { - $query = "SELECT * FROM Source WHERE date = :d"; - - $this -> co -> executeQuery($query, ["date" => array($d, PDO::PARAM_STR)]); - $res = $this -> co -> getResults(); - - if ($res) - return new sourceEntity( - $res["id_source"], - $res["title"], - $res["date"] - ); - return null; - } - - public function findAll() : array - { - $query = "SELECT * FROM Source"; - - $this -> co -> executeQuery($query); - $res = $this -> co -> getResults(); - - $sources = []; - - foreach ($res as $source) { - $sources[] = new sourceEntity( - $source["id_source"], - $source["title"], - $source["date"] - ); - } - return $sources; - } - - public function delete(int $id) : bool - { - $query = "DELETE FROM Source WHERE id_source = :id_s"; - - $this -> co -> executeQuery($query, ["id_s" => array($id, PDO::PARAM_INT)]); - } - - public function update(sourceEntity $s) : bool - { - $query = " - UPDATE Source - SET title = :t, date = :d - WHERE id_source = :id_s - "; - return $this->co->executeQuery($query, [ - "id_s" => array($s -> getIdSource(), PDO::PARAM_INT), - "t" => array($s -> getTitle(), PDO::PARAM_STR), - "d" => array($s -> getDate(), PDO::PARAM_STR) - ]); - } - -} \ No newline at end of file