Créé dans le cadre du projet de fin d'année de la promo 2018 de CIR2 de l'ISEN Brest/Rennes, le Burger Quizz est une adaptation numérique du jeu télévisé éponyme, plus précisément d'une épreuve spécifique de ce jeu : le "Sel ou Poivre".

class.categorie.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. class Categorie {
  3. private $bdd;
  4. private $nomCat;
  5. private $questsets;
  6. function __construct($nomCat) {
  7. $this->bdd = new Connector();
  8. $this->selectCat($nomCat);
  9. $this->questsets = array();
  10. $this->load();
  11. }
  12. private function selectCat($nomCat) {
  13. $options = array(
  14. "where" => array(
  15. array("nom_cat", "=", $nomCat)
  16. )
  17. );
  18. if(!is_null($this->bdd->Select('*', 'categorie', $options))) {
  19. $this->nomCat = $nomCat;
  20. } else {
  21. throw new Exception('Catégorie introuvable');
  22. }
  23. }
  24. private function load() {
  25. $options = array(
  26. "where" => array(
  27. array("nom_cat", "=", $this->nomCat)
  28. )
  29. );
  30. $resp = $this->bdd->Select('*', 'reponses', $options);
  31. foreach($resp as $questset) {
  32. array_push($this->questsets, new Questset(array($questset['reponse1'], $questset['reponse2'])));
  33. }
  34. }
  35. public static function randSelect() {
  36. $bdd = new Connector();
  37. $arrayCat = $bdd->Select("*", "categorie");
  38. $return = array();
  39. for($i = 0; $i < 2; $i++) {
  40. $catIndex = rand(0, sizeof($arrayCat));
  41. array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
  42. }
  43. return $return;
  44. }
  45. }