Lang.php 1.4 KB

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