Skill_Level.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 'skill_level'.
  17. *
  18. * @category Entity
  19. */
  20. class 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. */
  42. public function __construct($skill, $level){
  43. $statement = get_context()->get_db()->prepare("
  44. SELECT
  45. skill,
  46. level,
  47. description
  48. FROM skill_level
  49. WHERE
  50. skill = :skill AND
  51. level = :level;
  52. ");
  53. $statement->bindValue(':skill', $skill, SQLITE3_TEXT);
  54. $statement->bindValue(':level', $level, SQLITE3_TEXT);
  55. $r = $statement->execute()->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. ?>