Project_Url.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["entity"] . "Project_Url_Type.php");
  4. /**
  5. * URL related to a project.
  6. *
  7. * Represents an object from the table 'project_url'.
  8. */
  9. class Project_Url extends Entity{
  10. /**
  11. * Identifier of the url.
  12. */
  13. public $id;
  14. /**
  15. * Identifier of the project the URL is related to.
  16. */
  17. public $project;
  18. /**
  19. * URL {@see Project_Url_Type}.
  20. */
  21. public $type;
  22. /**
  23. * Full URL address.
  24. */
  25. public $url;
  26. /**
  27. * Constructor.
  28. *
  29. * Searches the database and retrieves the information about the
  30. * url, populating it and its items.
  31. *
  32. * @param MySQL_connection $db Connection to the database.
  33. * @param string $lang Lowercase, two-letter language code.
  34. * @param int $id Identifier of the url.
  35. */
  36. public function __construct($db, $lang, $id){
  37. parent::__construct($db, $lang);
  38. $s =
  39. "SELECT " .
  40. " id, " .
  41. " project, " .
  42. " type, " .
  43. " url " .
  44. "FROM project_url " .
  45. "WHERE id = $id ;";
  46. $q = mysqli_query($this->db, $s);
  47. if (mysqli_num_rows($q) > 0){
  48. $r = mysqli_fetch_array($q);
  49. $this->id = $r["id"];
  50. $this->project = $r["project"];
  51. $this->url = $r["url"];
  52. $this->type = new Project_Url_Type($this->db, $this->lang, $r["type"]);
  53. }
  54. }
  55. }
  56. ?>