Decoration.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $statement = $db->prepare("
  46. SELECT
  47. uid,
  48. decoration,
  49. level
  50. FROM decoration
  51. WHERE id = :id;
  52. ");
  53. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  54. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  55. if ($r){
  56. $this->uid = $r["uid"];
  57. $this->decoration = new K_Decoration($r["decoration"]);
  58. $this->level = $r["level"];
  59. }
  60. }
  61. }
  62. ?>