K_Skill_Level.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Skill level 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. * Monster skill level.
  15. *
  16. * Represents an object from the table 'k_monster_skill_upgrade'.
  17. *
  18. * @category Entity
  19. */
  20. class K_Skill_Level extends Entity{
  21. /**
  22. * @var int Skill identifier.
  23. */
  24. public $skill;
  25. /**
  26. * @var int Skill level.
  27. */
  28. public $level;
  29. /**
  30. * @var string Upgrade description.
  31. */
  32. public $description;
  33. /**
  34. * Constructor.
  35. *
  36. * Searches the database and retrieves the information about the
  37. * skill level, populating it and it's items.
  38. *
  39. * @param resource $db Connection to the database.
  40. * @param int $skill Skill identifier.
  41. * @param int $level Skill level.
  42. */
  43. public function __construct($db, $skill, $level){
  44. parent::__construct($db);
  45. $s =
  46. "SELECT " .
  47. " skill, " .
  48. " level, " .
  49. " description " .
  50. "FROM k_skill_level " .
  51. "WHERE " .
  52. " skill = $skill AND " .
  53. " level = $level;";
  54. $q = $this->db->query($s);
  55. $r = $q->fetchArray(SQLITE3_ASSOC);
  56. if ($r){
  57. $this->skill = $r["skill"];
  58. $this->level = $r["level"];
  59. $this->description = HTML::e($r["description"]);
  60. }
  61. }
  62. }
  63. ?>