Place.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Place.
  5. *
  6. * Represents an object from the table 'sponsor'.
  7. */
  8. class Place extends Entity{
  9. /**
  10. * Identifier.
  11. */
  12. public $id;
  13. /**
  14. * Name of the place.
  15. */
  16. public $name;
  17. /**
  18. * Place address.
  19. */
  20. public $address;
  21. /**
  22. * Postal code.
  23. */
  24. public $cp;
  25. /**
  26. * Geographical location.
  27. */
  28. public $location = [
  29. "lat" => null,
  30. "lon" => null
  31. ];
  32. /**
  33. * Constructor.
  34. *
  35. * Searches the database and retrieves the information about the
  36. * entity, populating it and it's items.
  37. *
  38. * @param db Connection to the database.
  39. * @param lang Lowercase, two-letter language code.
  40. * @param id Identifier.
  41. */
  42. public function __construct($db, $lang, $id){
  43. parent::__construct($db, $lang);
  44. $s =
  45. "SELECT " .
  46. " id, " .
  47. " name_$lang AS name, " .
  48. " address_$lang AS address, " .
  49. " cp, " .
  50. " lat, " .
  51. " lon " .
  52. "FROM place " .
  53. "WHERE id = $id;";
  54. $q = mysqli_query($this->db, $s);
  55. if (mysqli_num_rows($q) > 0){
  56. $r = mysqli_fetch_array($q);
  57. $this->id = $r["id"];
  58. $this->name = $r["name"];
  59. $this->address = $r["address"];
  60. $this->cp = $r["cp"];
  61. $this->location["lat"] = $r["lat"];
  62. $this->location["lon"] = $r["lon"];
  63. }
  64. }
  65. }
  66. ?>