| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- /**
- * Game Server entity file.
- *
- * Creates the entity and makes it available.
- *
- * @author Iñigo Valentin <i@inigovalentin.com>
- * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
- * @package SWDB
- */
- require_once(PATH::ENTITY . "Entity.php");
- /**
- * Game Server.
- *
- * Represent a game server for an account
- *
- * @category Entity
- */
- class Server extends Entity{
- /**
- * @var int Server identifier.
- */
- private $id;
- /**
- * @var string Server name.
- */
- private $name;
- /**
- * Constructor.
- *
- * Searches the database and retrieves the information about the
- * server, populating it and it's items.
- *
- * @param int $id Server identifier.
- */
- public function __construct($id){
- $statement = get_context()->get_db()->prepare("
- SELECT
- id,
- name
- FROM server
- WHERE id = :id;
- ");
- $statement->bindValue(':id', $id, SQLITE3_TEXT);
- $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
- if ($r){
- $this->id = $r["id"];
- $this->name = HTML::e($r["name"]);
- }
- }
- /**
- * Retrieves the server identifier.
- *
- * @return int Server ID.
- */
- public function get_id(){
- return $this->id;
- }
- /**
- * Retrieves the server name name.
- *
- * @return string Server name.
- */
- public function get_name(){
- return $this->name;
- }
- }
|