Guild_Member.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * Guild member 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. /**
  14. * Guild.
  15. *
  16. * Represents an object from the table 'guild'.
  17. *
  18. * @category Entity
  19. */
  20. class Guild_Member extends Entity{
  21. /**
  22. * @var int Member identifier.
  23. */
  24. public $id;
  25. /**
  26. * @var int Guild id.
  27. */
  28. public $guild;
  29. /**
  30. * @var string Member name.
  31. */
  32. public $name;
  33. /**
  34. * @var int Member level.
  35. */
  36. public $level;
  37. /**
  38. * @var int Member grade.
  39. */
  40. public $grade;
  41. /**
  42. * @var int Memeber rating.
  43. */
  44. public $rating;
  45. /**
  46. * @var int Memebr arena score.
  47. */
  48. public $arena_score;
  49. /**
  50. * @var DateTime Time the user joined the guild at.
  51. */
  52. public $joined;
  53. /**
  54. * @var Datetime Time the user last log on at.
  55. */
  56. public $last_login;
  57. /**
  58. * @var bool Indicates if the member is included in guild wars.
  59. */
  60. public $in_war;
  61. /**
  62. * @var bool Indicates if the member has set guild wars defenses.
  63. */
  64. public $has_defense;
  65. /**
  66. * Constructor.
  67. *
  68. * Searches the database and retrieves the information about the
  69. * guild, populating it and it's items.
  70. *
  71. * @param resource $db Connection to the database.
  72. * @param int $id Guild identifier.
  73. */
  74. public function __construct($db, $id){
  75. global $path;
  76. parent::__construct($db);
  77. $s =
  78. "SELECT " .
  79. " id, " .
  80. " guild, " .
  81. " name, " .
  82. " level, " .
  83. " grade, " .
  84. " rating, " .
  85. " arena_score, " .
  86. " joined, " .
  87. " last_login, " .
  88. " in_war, " .
  89. " has_defense " .
  90. "FROM guild_member " .
  91. "WHERE id = $id; ";
  92. $q = $this->db->query($s);
  93. $r = $q->fetchArray(SQLITE3_ASSOC);
  94. if ($r){
  95. $this->id = $r["id"];
  96. $this->guild = $r["guild"];
  97. $this->name = HTML::e($r["name"]);
  98. $this->level = $r["level"];
  99. $this->grade = $r["grade"];
  100. $this->rating = $r["rating"];
  101. $this->arena_score = $r["arena_score"];
  102. $this->joined = $r["joined"];
  103. $this->last_login = $r["last_login"];
  104. $this->in_war = $r["in_war"];
  105. $this->has_defense = $r["has_defense"];
  106. }
  107. }
  108. }
  109. ?>