Festival_Offer.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Festival_Offer.
  5. *
  6. * Represents an object from the table 'festival_offer'.
  7. */
  8. class Festival_Offer extends Entity{
  9. /**
  10. * Identifier.
  11. */
  12. public $id;
  13. /**
  14. * Year the offer applies on.
  15. */
  16. public $year;
  17. /**
  18. * Offer name.
  19. */
  20. public $name;
  21. /**
  22. * Offer description.
  23. */
  24. public $description;
  25. /**
  26. * Prices of the offer.
  27. */
  28. public $price = [
  29. "public" => null,
  30. "member" => null
  31. ];
  32. /**
  33. * Number of days included in the offer.
  34. */
  35. public $days;
  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. " year, " .
  52. " name_$lang AS name, " .
  53. " description_$lang AS description, " .
  54. " price, " .
  55. " price_public, " .
  56. " days " .
  57. "FROM festival_offer " .
  58. "WHERE id = $id;";
  59. $q = mysqli_query($this->db, $s);
  60. if (mysqli_num_rows($q) > 0){
  61. $r = mysqli_fetch_array($q);
  62. $this->id = $r["id"];
  63. $this->year = $r["year"];
  64. $this->name = $r["name"];
  65. $this->description = $r["description"];
  66. $this->price->member = $r["price"];
  67. $this->price->public = $r["price_public"];
  68. $this->days = $r["days"];
  69. }
  70. }
  71. }
  72. ?>