Activity_Itinerary.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["entity"] . "Route.php");
  4. require_once($path["entity"] . "Place.php");
  5. /**
  6. * Activity_Itinerary.
  7. *
  8. * Represents an object from the table 'activity_itinerary'.
  9. */
  10. class Activity_Itinerary extends Entity{
  11. /**
  12. * Identifier.
  13. */
  14. public $id;
  15. /**
  16. * Short name of the itinerary item.
  17. */
  18. public $name;
  19. /**
  20. * Description of the itinerary entry.
  21. */
  22. public $description;
  23. /**
  24. * Start time of the item.
  25. */
  26. public $start;
  27. /**
  28. * End time of the item. It may not be defined.
  29. */
  30. public $end;
  31. /**
  32. * Place of the item.
  33. */
  34. public $place;
  35. /**
  36. * Route the itinerary will travel during the item. It may be undefined.
  37. */
  38. public $route;
  39. /**
  40. * Constructor.
  41. *
  42. * Searches the database and retrieves the information about the
  43. * entity, populating it and it's items.
  44. *
  45. * @param db Connection to the database.
  46. * @param lang Lowercase, two-letter language code.
  47. * @param id Identifier.
  48. */
  49. public function __construct($db, $lang, $id){
  50. parent::__construct($db, $lang);
  51. $s =
  52. "SELECT " .
  53. " id, " .
  54. " name_$lang AS name, " .
  55. " description_$lang AS description, " .
  56. " start, " .
  57. " end, " .
  58. " place, " .
  59. " route " .
  60. "FROM activity_itinerary " .
  61. "WHERE id = $id;";
  62. $q = mysqli_query($this->db, $s);
  63. if (mysqli_num_rows($q) > 0){
  64. $r = mysqli_fetch_array($q);
  65. $this->id = $r["id"];
  66. $this->name = $r["name"];
  67. $this->description = $r["description"];
  68. $this->start = $r["start"];
  69. if (!is_null($r["end"])){
  70. $this->end = $r["end"];
  71. }
  72. $this->place = new Place($this->db, $this->lang, $r["place"]);
  73. if (!is_null($r["route"])){
  74. $this->route = new Route($this->db, $r["route"]);
  75. }
  76. }
  77. }
  78. }
  79. ?>