diff --git a/app/controller/JeuController.php b/app/controller/JeuController.php new file mode 100644 index 0000000000000000000000000000000000000000..e6d070a6890423e7fecd22c323651a5dfb979a79 --- /dev/null +++ b/app/controller/JeuController.php @@ -0,0 +1,10 @@ +<?php + +class JeuController extends Controller { + public function display() { + $slug = $this->route["params"]["slug"]; + $this->view->jeu = Jeu::getFromSlug($slug); + $this->view->display(); + } + +} diff --git a/app/model/Jeu.php b/app/model/Jeu.php new file mode 100644 index 0000000000000000000000000000000000000000..df1905a4f8a0edbde3eaa42ec191ab8f6ac952d3 --- /dev/null +++ b/app/model/Jeu.php @@ -0,0 +1,27 @@ +<?php + +class Jeu extends Model { + public $id, $nom, $description, $slug; + + public static function getFromSlug($slug) { + $db = Database::getInstance(); + $sql = "SELECT * FROM jeux WHERE slug = :slug"; + $stmt = $db->prepare($sql); + $stmt->setFetchMode(PDO::FETCH_CLASS, "Jeu"); + $stmt->execute(array(":slug" => $slug)); + return $stmt->fetch(); + } + + public static function getList() { + $db = Database::getInstance(); + $sql = "SELECT * FROM jeux"; + $stmt = $db->query($sql); + $stmt->setFetchMode(PDO::FETCH_CLASS, "Jeu"); + return $stmt->fetchAll(); + + } + +} + + + diff --git a/app/view/jeu/display.html b/app/view/jeu/display.html new file mode 100644 index 0000000000000000000000000000000000000000..f3d467e7e5c214c71e1b47571df60c1192826a4a --- /dev/null +++ b/app/view/jeu/display.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"/> + <title>Affichage d'un jeu</title> + <base href="http://localhost/projet-web-2016/www/"/> +</head> +<body> + <header> + <h1>Exemple d'affichage d'un jeu</h1> + </header> + <h2><?php echo $this->jeu->nom; ?></h2> + <h3><?php echo $this->jeu->description; ?></h3> + <footer> + <p>Pied de page...</p> + </footer> +</body> + + +</html>