| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- /**
- * Guild entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- require_once(PATH::ENTITY . "Guild_Member.php");
- /**
- * Guild.
- *
- * Represents an object from the table 'guild'.
- *
- * @category Entity
- */
- class Guild extends Entity{
- /**
- * @var int @var int Guild identifier.
- */
- public $id;
- /**
- * @var int @var string Guild name.
- */
- public $name;
- /**
- * @var int @var int Guild level.
- */
- public $level;
- /**
- * @var int Guild total experience.
- */
- public $experience;
- /**
- * @var bool Indicates if the guild is ecruiting.
- */
- public $recruiting;
- /**
- * @var int Number of members.
- */
- public $total_members;
- /**
- * @var GUild_Member Guild Leader.
- */
- public $leader;
- /**
- * @var string Guild comment.
- */
- public $comment;
- /**
- * @var string Guild notice.
- */
- public $notice;
- /**
- * @var \Guild_Member[] List of {@see Guild_Member}s.
- */
- public $members = [];
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * guild, populating it and it's items.
- *
- * @param int $id Guild identifier.
- * @global resource Database connection.
- */
- public function __construct($id){
- global $db;
- $s =
- "SELECT " .
- " id, " .
- " name, " .
- " name, " .
- " level, " .
- " experience, " .
- " recruiting, " .
- " members, " .
- " leader, " .
- " comment, " .
- " notice " .
- "FROM guild " .
- "WHERE id = $id; ";
- $q = $db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->id = $r["id"];
- $this->name = HTML::e($r["name"]);
- $this->level = $r["level"];
- $this->experience = $r["experience"];
- $this->recruiting = $r["recruiting"];
- $this->total_members = $r["members"];
- $this->leader = $r["leader"];
- $this->comment = HTML::e($r["comment"]);
- $this->notice = HTML::e($r["notice"]);
- }
- $s =
- "SELECT id " .
- "FROM guild_member " .
- "WHERE guild = $this->id " .
- "ORDER BY " .
- " grade = 1 DESC, " .
- " grade = 3 DESC, " .
- " grade = 2 DESC, " .
- " arena_score DESC; ";
- $q = $db->query($s);
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->members, new Guild_Member($r["id"]));
- }
- }
- }
- ?>
|