People.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * People.
  5. *
  6. * Represents an object from the table 'people'.
  7. */
  8. class People extends Entity{
  9. /**
  10. * Identifier.
  11. */
  12. public $id;
  13. /**
  14. * Name of the sponsor.
  15. */
  16. public $name;
  17. /**
  18. * Person url.
  19. */
  20. public $link;
  21. /**
  22. * Constructor.
  23. *
  24. * Searches the database and retrieves the information about the
  25. * entity, populating it and it's items.
  26. *
  27. * @param db Connection to the database.
  28. * @param lang Lowercase, two-letter language code.
  29. * @param id Identifier.
  30. */
  31. public function __construct($db, $lang, $id){
  32. parent::__construct($db, $lang);
  33. $s =
  34. "SELECT " .
  35. " id, " .
  36. " name_$lang AS name, " .
  37. " link " .
  38. "FROM people " .
  39. "WHERE id = '$id';";
  40. $q = mysqli_query($this->db, $s);
  41. if (mysqli_num_rows($q) > 0){
  42. $r = mysqli_fetch_array($q);
  43. $this->id = $r["id"];
  44. $this->name = $r["name"];
  45. $this->link = $r["link"];
  46. }
  47. }
  48. }
  49. ?>