| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /**
- * Building entity file.
- *
- * Creates the entity and makes it available.
- *
- * @category Entity
- */
- /**
- * Require dependent entities if not present.
- */
- require_once(PATH::ENTITY . "Entity.php");
- require_once(PATH::ENTITY . "K_Building.php");
- /**
- * A Building.
- *
- * Represents an object from the table 'building'.
- *
- * @category Entity
- */
- class Building extends Entity{
- /**
- * @var int Owner identifier.
- */
- public $uid;
- /**
- * @var K_Building Base building.
- */
- public $building;
- /**
- * @var int Gain per horu.
- */
- public $gain;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * building, populating it and it's items.
- *
- * @param int $id Building identifier.
- * @global resource Database connection.
- */
- public function __construct($id){
- global $db;
- $s = "
- SELECT
- uid,
- building,
- gain
- FROM building
- WHERE id = $id;
- ";
- $q = $db->query($s);
- $r = $q->fetchArray(SQLITE3_ASSOC);
- $this->uid = $r["uid"];
- $this->building = new K_Building($r["building"]);
- $this->gain = $r["gain"];
- }
- }
- ?>
|