Activity_Image.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Activity_Image.
  5. *
  6. * Represents an object from the table 'activity_image'.
  7. */
  8. class Activity_Image extends Entity{
  9. /**
  10. * Identifier.
  11. */
  12. public $id;
  13. /**
  14. * Identifier of the activity the image belongs to.
  15. */
  16. public $activity;
  17. /**
  18. * Filename.
  19. */
  20. public $image;
  21. /**
  22. * Order.
  23. */
  24. public $idx;
  25. /**
  26. * Constructor.
  27. *
  28. * Searches the database and retrieves the information about the
  29. * entity, populating it and it's items.
  30. *
  31. * @param db Connection to the database.
  32. * @param id Identifier.
  33. */
  34. public function __construct($db, $id){
  35. parent::__construct($db, null);
  36. $s =
  37. "SELECT " .
  38. " id, " .
  39. " activity, " .
  40. " image, " .
  41. " idx " .
  42. "FROM activity_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->activity = $r["activity"];
  49. $this->image = $r["image"];
  50. $this->idx = $r["idx"];
  51. }
  52. }
  53. }
  54. ?>