From 1b1410fffd7105368fd946b04fb7746596a500eb Mon Sep 17 00:00:00 2001 From: libreton Date: Wed, 25 Oct 2023 16:44:10 +0200 Subject: [PATCH] =?UTF-8?q?ADD:=20d=C3=A9but=20classes=20du=20mod=C3=A8le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 + .idea/Neutral.iml | 8 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + project/src/index.php | 33 +++++ project/src/model/gateways/Connection.php | 36 +++++ .../src/model/gateways/ScientistGateway.php | 8 + project/src/model/metier/Difficulty.php | 10 ++ project/src/model/metier/Scientist.php | 138 ++++++++++++++++++ project/src/model/metier/Theme.php | 10 ++ 10 files changed, 265 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Neutral.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 project/src/model/gateways/Connection.php create mode 100644 project/src/model/gateways/ScientistGateway.php create mode 100644 project/src/model/metier/Difficulty.php create mode 100644 project/src/model/metier/Scientist.php create mode 100644 project/src/model/metier/Theme.php diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/Neutral.iml b/.idea/Neutral.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/Neutral.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..22af70c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/project/src/index.php b/project/src/index.php index b3d9bbc..81dc0eb 100644 --- a/project/src/index.php +++ b/project/src/index.php @@ -1 +1,34 @@ + + + +test + executeQuery($query, array(':id' => array(1, PDO::PARAM_INT) ) ); + + $results=$con->getResults(); + Foreach ($results as $row) + print $row['titre']; + + +} +catch( PDOException $Exception ) { + echo 'erreur'; + echo $Exception->getMessage();} +?> + + + \ No newline at end of file diff --git a/project/src/model/gateways/Connection.php b/project/src/model/gateways/Connection.php new file mode 100644 index 0000000..1cba4d0 --- /dev/null +++ b/project/src/model/gateways/Connection.php @@ -0,0 +1,36 @@ +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(); + + } +} \ No newline at end of file diff --git a/project/src/model/gateways/ScientistGateway.php b/project/src/model/gateways/ScientistGateway.php new file mode 100644 index 0000000..38931d2 --- /dev/null +++ b/project/src/model/gateways/ScientistGateway.php @@ -0,0 +1,8 @@ +id = $id; + $this->name = $name; + $this->firstName = $firstName; + $this->photo = $photo; + $this->description = $description; + $this->theme = $theme; + $this->difficulty = $difficulty; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName(string $name): void + { + $this->name = $name; + } + + /** + * @return string + */ + public function getFirstName(): string + { + return $this->firstName; + } + + /** + * @param string $firstName + */ + public function setFirstName(string $firstName): void + { + $this->firstName = $firstName; + } + + /** + * @return string + */ + public function getPhoto(): string + { + return $this->photo; + } + + /** + * @param string $photo + */ + public function setPhoto(string $photo): void + { + $this->photo = $photo; + } + + /** + * @return string + */ + public function getDescription(): string + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription(string $description): void + { + $this->description = $description; + } + + /** + * @return Theme + */ + public function getTheme(): Theme + { + return $this->theme; + } + + /** + * @param Theme $theme + */ + public function setTheme(Theme $theme): void + { + $this->theme = $theme; + } + + /** + * @return Difficulty + */ + public function getDifficulty(): Difficulty + { + return $this->difficulty; + } + + /** + * @param Difficulty $difficulty + */ + public function setDifficulty(Difficulty $difficulty): void + { + $this->difficulty = $difficulty; + } +} \ No newline at end of file diff --git a/project/src/model/metier/Theme.php b/project/src/model/metier/Theme.php new file mode 100644 index 0000000..5900456 --- /dev/null +++ b/project/src/model/metier/Theme.php @@ -0,0 +1,10 @@ +