Decoration.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 int $id Building identifier.
  41. * @global resource Database connection.
  42. */
  43. public function __construct($id){
  44. global $db;
  45. $s = "
  46. SELECT
  47. uid,
  48. decoration,
  49. level
  50. FROM decoration
  51. WHERE id = $id;
  52. ";
  53. $q = $db->query($s);
  54. $r = $q->fetchArray(SQLITE3_ASSOC);
  55. $this->uid = $r["uid"];
  56. $this->decoration = new K_Decoration($r["decoration"]);
  57. $this->level = $r["level"];
  58. }
  59. }
  60. ?>