Project_Image.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Image of a project.
  5. *
  6. * Represents an object from the table 'project_image'.
  7. */
  8. class Project_Image extends Entity{
  9. /**
  10. * Image identifier.
  11. */
  12. public $id;
  13. /**
  14. * Project identifier.
  15. */
  16. public $project;
  17. /**
  18. * Indicates the order position among other images.
  19. */
  20. public $idx;
  21. /**
  22. * Filename of the image.
  23. */
  24. public $image;
  25. /**
  26. * Constructor.
  27. *
  28. * Searches the database and retrieves the information about the
  29. * image, populating it.
  30. *
  31. * @param MySQL_connection $db Connection to the database.
  32. * @param int $id Identifier of the image.
  33. */
  34. public function __construct($db, $id){
  35. parent::__construct($db, null);
  36. $s =
  37. "SELECT " .
  38. " id, " .
  39. " project, " .
  40. " idx, " .
  41. " image " .
  42. "FROM project_image " .
  43. "WHERE id = $id ;";
  44. $q = mysqli_query($this->db, $s);
  45. if (mysqli_num_rows($q) > 0){
  46. $r = mysqli_fetch_array($q);
  47. $this->id = $r["id"];
  48. $this->project = $r["project"];
  49. $this->idx = $r["idx"];
  50. $this->image = $r["image"];
  51. }
  52. }
  53. }
  54. ?>