K_Skill_Level.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 int $skill Skill identifier.
  40. * @param int $level Skill level.
  41. * @global resource Database connection.
  42. */
  43. public function __construct($skill, $level){
  44. global $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 = $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. ?>