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 @@ +