Decoration.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * Decoration entity file.
  4. *
  5. * Creates the entity and makes it available.
  6. *
  7. * @category Entity
  8. */
  9. /**
  10. * Require dependent entities if not present.
  11. */
  12. require_once(PATH::ENTITY . "Entity.php");
  13. require_once(PATH::ENTITY . "Decorative.php");
  14. /**
  15. * A Decoration.
  16. *
  17. * Represents an object from the table 'decoration'.
  18. *
  19. * @category Entity
  20. */
  21. class Decoration extends Entity{
  22. private $player_id;
  23. private $decorative;
  24. private $level;
  25. /**
  26. * Constructor.
  27. *
  28. * Searches the database and retrieves the information about the
  29. * decoration, populating it and it's items.
  30. *
  31. * @param int $id Building identifier.
  32. */
  33. public function __construct($id){
  34. $statement = get_context()->get_db()->prepare("
  35. SELECT
  36. player,
  37. decorative,
  38. level
  39. FROM decoration
  40. WHERE id = :id;
  41. ");
  42. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  43. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  44. if ($r){
  45. $this->player = $r["player"];
  46. $this->decorative = new Decorative($r["decorative"]);
  47. $this->level = $r["level"];
  48. }
  49. }
  50. /**
  51. * Retrieves the owner's player id.
  52. *
  53. * @return int Player ID.
  54. */
  55. public function get_player_id(){
  56. return $this->player_id;
  57. }
  58. /**
  59. * Retrieves the base decorative structure.
  60. *
  61. * @return Decorative Base decorative.
  62. */
  63. public function get_decorative(){
  64. return $this->decorative;
  65. }
  66. /**
  67. * Retrieves the decoration level.
  68. *
  69. * @return int Decoration level.
  70. */
  71. public function get_level(){
  72. return $this->level;
  73. }
  74. }
  75. ?>