<?php

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


    /**
     * A Decoration.
     *
     * Represents an object from the table 'decoration'.
     */
    class Decoration extends Entity{

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

        /**
         * {@see K_Decoration}.
         */
        public $decoration;

        /**
         * I honestly don't know what the gin is.
         */
        public $level;

        /**
         * Constructor.
         *
         * Searches the database and retrieves the information about the
         * decoration, populating it and it's items.
         *
         * @param SQLite3 $db Connection to the database.
         * @param int $id Building identifier.
         */
        public function __construct($db, $id){
            global $path;
            parent::__construct($db);
            $s = "
                SELECT
                  uid,
                  decoration,
                  level
                FROM decoration
                WHERE decoration = $id;
            ";
            $q = $this->db->query($s);
            $r = $q->fetchArray(SQLITE3_ASSOC);
            $this->uid = $r["uid"];
            $this->decoration = new K_Decoration($this->db, $r["decoration"]);
            $this->level = $r["level"];
        }
    }
?>
