Custom_Filter.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Custom filter 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. * A custom_Filter.
  15. *
  16. * Represents an object from the table 'filter'.
  17. *
  18. * @category Entity
  19. */
  20. class Custom_Filter extends Entity{
  21. /**
  22. * @var int Player identifier.
  23. */
  24. public $uid;
  25. /**
  26. * @var int Filter identifier.
  27. */
  28. public $id;
  29. /**
  30. * @var string Name of the pge the filter is for.
  31. */
  32. public $page;
  33. /**
  34. * @var string Filter name.
  35. */
  36. public $name;
  37. /**
  38. * @var string Filter description.
  39. */
  40. public $description;
  41. /**
  42. * @var string Filter condition (sql where clause).
  43. */
  44. public $condition;
  45. /**
  46. * Constructor.
  47. *
  48. * Searches the database and retrieves the information about the
  49. * run, populating it and it's items.
  50. *
  51. * @param resource $db Connection to the database.
  52. * @param int $id Filter identifier.
  53. */
  54. public function __construct($db, $id){
  55. parent::__construct($db);
  56. $s = "
  57. SELECT
  58. uid,
  59. id,
  60. page,
  61. name,
  62. description,
  63. condition
  64. FROM filter
  65. WHERE id = $id;
  66. ";
  67. $q = $this->db->query($s);
  68. $r = $q->fetchArray(SQLITE3_ASSOC);
  69. $this->id = $r["id"];
  70. $this->uid = $r["uid"];
  71. $this->page = $r["page"];
  72. $this->name = HTML::e($r["name"]);
  73. $this->description = $r["description"]; // Must be properly formated!
  74. $this->condition = $r["condition"];
  75. }
  76. }
  77. ?>