From 8b5783f187b034a3ad3c1e1e8e66e6fa2e6c0527 Mon Sep 17 00:00:00 2001 From: maxime point Date: Wed, 8 Nov 2023 17:20:16 +0100 Subject: [PATCH] ajout connection --- mvc_PSR4_twig/composer.json | 3 +- mvc_PSR4_twig/modeles/Connection.php | 44 +++++++++++++++++++++++++++ mvc_PSR4_twig/modeles/Flux.php | 8 +++++ mvc_PSR4_twig/modeles/FluxGateway.php | 8 +++++ mvc_PSR4_twig/modeles/FluxModel.php | 8 +++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 mvc_PSR4_twig/modeles/Connection.php create mode 100644 mvc_PSR4_twig/modeles/Flux.php create mode 100644 mvc_PSR4_twig/modeles/FluxGateway.php create mode 100644 mvc_PSR4_twig/modeles/FluxModel.php diff --git a/mvc_PSR4_twig/composer.json b/mvc_PSR4_twig/composer.json index de876b8..0c6dfa6 100755 --- a/mvc_PSR4_twig/composer.json +++ b/mvc_PSR4_twig/composer.json @@ -1,6 +1,7 @@ { "require": { - "twig/twig": "^3.0" + "twig/twig": "^3.0", + "ext-pdo": "*" }, "autoload": { "psr-4": { diff --git a/mvc_PSR4_twig/modeles/Connection.php b/mvc_PSR4_twig/modeles/Connection.php new file mode 100644 index 0000000..da7062f --- /dev/null +++ b/mvc_PSR4_twig/modeles/Connection.php @@ -0,0 +1,44 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + + /** + * @param string $query to execute + * @param array $parameters to bind + * @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(); + } + + /** + * @return array + */ + public function getResults(): array + { + return $this->stmt->fetchall(); + } +} \ No newline at end of file diff --git a/mvc_PSR4_twig/modeles/Flux.php b/mvc_PSR4_twig/modeles/Flux.php new file mode 100644 index 0000000..e99d929 --- /dev/null +++ b/mvc_PSR4_twig/modeles/Flux.php @@ -0,0 +1,8 @@ +