Festival_Day.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Festival_Day.
  5. *
  6. * Represents an object from the table 'festival_day'.
  7. */
  8. class Festival_Day extends Entity{
  9. /**
  10. * Identifier.
  11. */
  12. public $id;
  13. /**
  14. * Date of the day.
  15. */
  16. public $date;
  17. /**
  18. * Day name.
  19. */
  20. public $name;
  21. /**
  22. * Prices of the day.
  23. */
  24. public $price = [
  25. "public" => null,
  26. "member" => null
  27. ];
  28. /**
  29. * Number of people inscribed for the day.
  30. */
  31. public $people;
  32. /**
  33. * Maximum number of people that can inscribe.
  34. */
  35. public $max_people;
  36. /**
  37. * Constructor.
  38. *
  39. * Searches the database and retrieves the information about the
  40. * entity, populating it and it's items.
  41. *
  42. * @param db Connection to the database.
  43. * @param lang Lowercase, two-letter language code.
  44. * @param id Identifier.
  45. */
  46. public function __construct($db, $lang, $id){
  47. parent::__construct($db, null);
  48. $s =
  49. "SELECT " .
  50. " id, " .
  51. " name_$lang AS name, " .
  52. " price, " .
  53. " price_public, " .
  54. " people, " .
  55. " max_people " .
  56. "FROM festival_day " .
  57. "WHERE id = $id;";
  58. $q = mysqli_query($this->db, $s);
  59. if (mysqli_num_rows($q) > 0){
  60. $r = mysqli_fetch_array($q);
  61. $this->id = $r["id"];
  62. $this->name = $r["name"];
  63. $this->price->member = $r["price"];
  64. $this->price->public = $r["price_public"];
  65. $this->people = $r["people"];
  66. $this->max_people = $r["max_people"];
  67. }
  68. }
  69. }
  70. ?>