Server.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Game Server entity file.
  4. *
  5. * Creates the entity and makes it available.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. require_once(PATH::ENTITY . "Entity.php");
  12. /**
  13. * Game Server.
  14. *
  15. * Represent a game server for an account
  16. *
  17. * @category Entity
  18. */
  19. class Server extends Entity{
  20. /**
  21. * @var int Server identifier.
  22. */
  23. private $id;
  24. /**
  25. * @var string Server name.
  26. */
  27. private $name;
  28. /**
  29. * Constructor.
  30. *
  31. * Searches the database and retrieves the information about the
  32. * server, populating it and it's items.
  33. *
  34. * @param int $id Server identifier.
  35. */
  36. public function __construct($id){
  37. $statement = get_context()->get_db()->prepare("
  38. SELECT
  39. id,
  40. name
  41. FROM server
  42. WHERE id = :id;
  43. ");
  44. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  45. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  46. if ($r){
  47. $this->id = $r["id"];
  48. $this->name = HTML::e($r["name"]);
  49. }
  50. }
  51. /**
  52. * Retrieves the server identifier.
  53. *
  54. * @return int Server ID.
  55. */
  56. public function get_id(){
  57. return $this->id;
  58. }
  59. /**
  60. * Retrieves the server name name.
  61. *
  62. * @return string Server name.
  63. */
  64. public function get_name(){
  65. return $this->name;
  66. }
  67. }