Server.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Game Server key entity file.
  4. *
  5. * Creates the entity and makes it available.
  6. *
  7. * @category Entity
  8. */
  9. /**
  10. * Require dependent entities if not present.
  11. */
  12. require_once(PATH::ENTITY . "Entity.php");
  13. /**
  14. * Game Server.
  15. *
  16. * Represents an object from the table 'server'.
  17. *
  18. * @category Entity
  19. */
  20. class Server extends Entity{
  21. /**
  22. * @var int Server identifier.
  23. */
  24. public $id;
  25. /**
  26. * @var string Server name.
  27. */
  28. public $name;
  29. /**
  30. * Constructor.
  31. *
  32. * Searches the database and retrieves the information about the
  33. * server, populating it and it's items.
  34. *
  35. * @param int $id Server identifier.
  36. */
  37. public function __construct($id){
  38. $statement = get_context()->get_db()->prepare("
  39. SELECT
  40. id,
  41. name
  42. FROM server
  43. WHERE id = :id;
  44. ");
  45. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  46. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  47. if ($r){
  48. $this->id = $r["id"];
  49. $this->name = HTML::e($r["name"]);
  50. }
  51. }
  52. }
  53. ?>