Building.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["entity"] . "K_Building.php");
  4. /**
  5. * A Building.
  6. *
  7. * Represents an object from the table 'building'.
  8. */
  9. class Building extends Entity{
  10. /**
  11. * Owner identifier.
  12. */
  13. public $uid;
  14. /**
  15. * {@see K_Building}.
  16. */
  17. public $building;
  18. /**
  19. * I honestly don't know what the gin is.
  20. */
  21. public $gain;
  22. /**
  23. * Constructor.
  24. *
  25. * Searches the database and retrieves the information about the
  26. * building, populating it and it's items.
  27. *
  28. * @param SQLite3 $db Connection to the database.
  29. * @param int $id Building identifier.
  30. */
  31. public function __construct($db, $id){
  32. global $path;
  33. parent::__construct($db);
  34. $s = "
  35. SELECT
  36. uid,
  37. building,
  38. gain
  39. FROM building
  40. WHERE building = $id;
  41. ";
  42. $q = $this->db->query($s);
  43. $r = $q->fetchArray(SQLITE3_ASSOC);
  44. $this->uid = $r["uid"];
  45. $this->building = new K_Building($this->db, $r["building"]);
  46. $this->gain = $r["gain"];
  47. }
  48. }
  49. ?>