Monster_Base.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Monster.
  5. *
  6. * Represents an object from the table 'monster_base'.
  7. */
  8. class Monster_Base extends Entity{
  9. /**
  10. * Project identifier.
  11. */
  12. public $id;
  13. /**
  14. * Monster name.
  15. */
  16. public $name;
  17. /**
  18. * Constructor.
  19. *
  20. * Searches the database and retrieves the information about the
  21. * base monster, populating it and it's items.
  22. *
  23. * @param SQLite3 $db Connection to the database.
  24. * @param int $id Base monster identifier.
  25. */
  26. public function __construct($db, $id){
  27. parent::__construct($db);
  28. $s =
  29. "SELECT " .
  30. " id, " .
  31. " name " .
  32. "FROM monster_base " .
  33. "WHERE id = $id; ";
  34. $q = $this->db->query($s);
  35. $r = $q->fetchArray(SQLITE3_ASSOC);
  36. if ($r){
  37. $this->id = $r["id"];
  38. $this->name = $r["name"];
  39. }
  40. }
  41. }
  42. ?>