Custom_Filter.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 int $id Filter identifier.
  52. * @global resource Database connection.
  53. */
  54. public function __construct($id){
  55. global $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 = $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. ?>