Decoration.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 . "K_Decoration.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. /**
  23. * @var int player identifier.
  24. */
  25. public $uid;
  26. /**
  27. * @var K_Decoration Base decoration.
  28. */
  29. public $decoration;
  30. /**
  31. * @var int decoration level.
  32. */
  33. public $level;
  34. /**
  35. * Constructor.
  36. *
  37. * Searches the database and retrieves the information about the
  38. * decoration, populating it and it's items.
  39. *
  40. * @param resource $db Connection to the database.
  41. * @param int $id Building identifier.
  42. */
  43. public function __construct($db, $id){
  44. parent::__construct($db);
  45. $s = "
  46. SELECT
  47. uid,
  48. decoration,
  49. level
  50. FROM decoration
  51. WHERE decoration = $id;
  52. ";
  53. $q = $this->db->query($s);
  54. $r = $q->fetchArray(SQLITE3_ASSOC);
  55. $this->uid = $r["uid"];
  56. $this->decoration = new K_Decoration($this->db, $r["decoration"]);
  57. $this->level = $r["level"];
  58. }
  59. }
  60. ?>