| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- /**
- * Guild skill group 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 . "K_Guild_Skill.php");
- /**
- * Guild skill group.
- *
- * Represents an object from the table 'k_guild_skill_group'.
- *
- * @category Entity
- */
- class K_Guild_Skill_Group extends Entity{
- /**
- * @var int Group identifier.
- */
- public $id;
- /**
- * @var string Group name.
- */
- public $name;
- /**
- * @var string Group description.
- */
- public $description;
- /**
- * @var \K_Guild_Skill[] List of K_Guild_Skills in the group.
- */
- public $skills = [];
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * skill group, populating it and it's items.
- *
- * @param int $id Skill group identifier.
- * @global resource Database connection.
- */
- public function __construct($id){
- global $db;
- $statement = $db->prepare("
- SELECT
- id,
- name,
- description
- FROM k_guild_skill_group
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->id = $r["id"];
- $this->name = HTML::e($r["name"]);
- $this->description = HTML::e($r["description"]);
- $statement = $db->prepare("
- SELECT id
- FROM k_guild_skill
- WHERE skill_group = :id;
- ");
- $statement->bindValue(':id', $this->id, SQLITE3_TEXT);
- $q = $statement->execute();
- while ($r = $q->fetchArray(SQLITE3_ASSOC)){
- array_push($this->skills, new K_Guild_Skill($r["id"]));
- }
- }
- }
- /**
- * Gets the pathto the monster image. The image must be in the
- * img/skill_guild/ directory, and its name must be the monster id,
- * padded with '0' to 1 digits, and the extension must be '.png'.
- *
- * @return string Image URL, or a fixed unknown image.
- */
- public function get_image(){
- return APPLICATION::img("SKILL_GUILD", $this->id);
- }
- }
- ?>
|