K_Skill_Level.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. $statement = $db->prepare("
  46. SELECT
  47. skill,
  48. level,
  49. description
  50. FROM k_skill_level
  51. WHERE
  52. skill = :skill AND
  53. level = :level;
  54. ");
  55. $statement->bindValue(':skill', $skill, SQLITE3_INTEGER);
  56. $statement->bindValue(':level', $level, SQLITE3_INTEGER);
  57. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  58. if ($r){
  59. $this->skill = $r["skill"];
  60. $this->level = $r["level"];
  61. $this->description = HTML::e($r["description"]);
  62. }
  63. }
  64. }
  65. ?>