Collection_New_Frame.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require_once($path["frame"] . "Frame.php");
  3. require_once($path["entity"] . "Monster.php");
  4. /**
  5. * Collection's page new monster form frame.
  6. */
  7. class Collection_New_Frame extends Frame{
  8. public $id;
  9. public $img;
  10. public $img_aw;
  11. public $element;
  12. /**
  13. * Selected {@see Monster}.
  14. */
  15. public $monster;
  16. /**
  17. * Constructor.
  18. *
  19. * Retrieves the data and initializes the variables.
  20. *
  21. * @param MySQL_connection $db Connection to the database.
  22. * @param Array $params Parameters array, containig at least 'base'
  23. * and 'element'.
  24. */
  25. public function __construct($db, $params){
  26. global $path;
  27. parent::__construct($db);
  28. $this->view = $path["view"] . "frame/new.php";
  29. $s =
  30. "SELECT monster.id AS id " .
  31. "FROM " .
  32. " monster, " .
  33. " monster_base " .
  34. "WHERE " .
  35. " monster.base = monster_base.id AND " .
  36. " upper(monster_base.name) = '" . strtoupper($params["base"]) . "' AND " .
  37. " monster.element = '" . $params["element"] . "'; ";
  38. $q = mysqli_query($this->db, $s);
  39. if (mysqli_num_rows($q) > 0){
  40. $r = mysqli_fetch_array($q);
  41. $this->monster = new Monster($this->db, $r["id"]);
  42. $this->id = $r["id"];
  43. $this->element = $params["element"];
  44. $this->img = $this->monster->image;
  45. $this->img_aw = $this->monster->image_aw;
  46. }
  47. }
  48. }
  49. ?>