| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?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;
- $statement = $db->prepare("
- SELECT
- uid,
- building,
- gain
- FROM building
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->uid = $r["uid"];
- $this->building = new K_Building($r["building"]);
- $this->gain = $r["gain"];
- }
- }
- }
- ?>
|