K_Server.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 'key.server'.
  17. *
  18. * @category Entity
  19. */
  20. class K_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. * @global resource Database connection.
  37. */
  38. public function __construct($id){
  39. global $db;
  40. $statement = $db->prepare("
  41. SELECT
  42. id,
  43. name
  44. FROM key.server
  45. WHERE id = :id;
  46. ");
  47. $statement->bindValue(':id', $id, SQLITE3_TEXT);
  48. $r = $statement->execute()->fetchArray(SQLITE3_ASSOC);
  49. if ($r){
  50. $this->id = $r["id"];
  51. $this->name = HTML::e($r["name"]);
  52. }
  53. }
  54. }
  55. ?>