Festival_Event.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["entity"] . "Route.php");
  4. require_once($path["entity"] . "Place.php");
  5. require_once($path["entity"] . "People.php");
  6. /**
  7. * Festival_Event.
  8. *
  9. * Represents an object from the table 'festival_event'.
  10. */
  11. class Festival_Event extends Entity{
  12. /**
  13. * Identifier.
  14. */
  15. public $id;
  16. /**
  17. * Indicates if the event is internal or an official event.
  18. */
  19. public $internal;
  20. /**
  21. * Event name.
  22. */
  23. public $title;
  24. /**
  25. * Description of the event.
  26. */
  27. public $description;
  28. /**
  29. * {@see People} hosting or organizing the event.
  30. */
  31. public $host;
  32. /**
  33. * {@see People} sponsoring the event.
  34. */
  35. public $sponsor;
  36. /**
  37. * Start time of the item.
  38. */
  39. public $start;
  40. /**
  41. * End time of the item. It may not be defined.
  42. */
  43. public $end;
  44. /**
  45. * Place of the item.
  46. */
  47. public $place;
  48. /**
  49. * Route the itinerary will travel during the item. It may be undefined.
  50. */
  51. public $route;
  52. /**
  53. * Interest of the event. Arbitrary.
  54. */
  55. public $interest;
  56. /**
  57. * Constructor.
  58. *
  59. * Searches the database and retrieves the information about the
  60. * entity, populating it and it's items.
  61. *
  62. * @param db Connection to the database.
  63. * @param lang Lowercase, two-letter language code.
  64. * @param id Identifier.
  65. */
  66. public function __construct($db, $lang, $id){
  67. parent::__construct($db, null);
  68. $s =
  69. "SELECT " .
  70. " id, " .
  71. " gm AS internal, " .
  72. " title_$lang AS title, " .
  73. " description_$lang AS description, " .
  74. " start, " .
  75. " end, " .
  76. " place, " .
  77. " route " .
  78. "FROM festival_event " .
  79. "WHERE id = $id;";
  80. $q = mysqli_query($this->db, $s);
  81. if (mysqli_num_rows($q) > 0){
  82. $r = mysqli_fetch_array($q);
  83. $this->id = $r["id"];
  84. $this->internal = $r["internal"];
  85. $this->title = $r["title"];
  86. $this->description = $r["description"];
  87. $this->start = $r["start"];
  88. if (!is_null($r["end"])){
  89. $this->end = $r["end"];
  90. }
  91. $this->place = new Place($this->db, $this->lang, $r["place"]);
  92. if (!is_null($r["route"])){
  93. $this->route = new Route($this->db, $this->lang, $r["route"]);
  94. }
  95. if (!is_null($r["host"])){
  96. $this->host = new People($this->db, $this->lang, $r["host"]);
  97. }
  98. if (!is_null($r["sponsor"])){
  99. $this->host = new Sponsor($this->db, $this->lang, $r["sponsor"]);
  100. }
  101. $this->interest = $r["interest"];
  102. }
  103. }
  104. }
  105. ?>