<?php

    require_once($path["entity"] . "Entity.php");

    /**
     * A custom_Filter.
     *
     * Represents an object from the table 'filter'.
     */
    class Custom_Filter extends Entity{

        /**
         * Player identifier.
         */
        public $uid;

        /**
         * Filter identifier.
         */
        public $id;

        /**
         * Name of the pge the filter is for.
         */
        public $page;

        /**
         * Filter name.
         */
        public $name;

        /**
         * Filter description.
         */
        public $description;

        /**
         * Filter condition.
         */
        public $condition;

        /**
         * Constructor.
         *
         * Searches the database and retrieves the information about the
         * run, populating it and it's items.
         *
         * @param SQLite3 $db Connection to the database.
         * @param int $id Filter identifier.
         */
        public function __construct($db, $id){
            parent::__construct($db);
            $s = "
                SELECT
                  uid,
                  id,
                  page,
                  name,
                  description,
                  condition
                FROM filter
                WHERE id = $id;
            ";
            $q = $this->db->query($s);
            $r = $q->fetchArray(SQLITE3_ASSOC);
            $this->id = $r["id"];
            $this->uid = $r["uid"];
            $this->page = $r["page"];
            $this->name = $r["name"];
            $this->description = $r["description"];
            $this->condition = $r["condition"];
        }

    }
?>
