Photo_Comment.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. /**
  4. * Photo_Comment.
  5. *
  6. * Represents an object from the table 'photo_comment'.
  7. */
  8. class Photo_Comment extends Entity{
  9. /**
  10. * Identifier.
  11. */
  12. public $id;
  13. /**
  14. * Identifier of the photo the comment belongs to.
  15. */
  16. public $photo;
  17. /**
  18. * The content in the defined language.
  19. */
  20. public $text;
  21. /**
  22. * Posting datetime.
  23. */
  24. public $dtime;
  25. /**
  26. * Uername.
  27. */
  28. public $username;
  29. /**
  30. * Language of the comment (unreliable).
  31. */
  32. public $lang;
  33. /**
  34. * Approved indicator.
  35. */
  36. public $approved;
  37. /**
  38. * Constructor.
  39. *
  40. * Searches the database and retrieves the information about the
  41. * entity, populating it and it's items.
  42. *
  43. * @param db Connection to the database.
  44. * @param id Identifier.
  45. */
  46. public function __construct($db, $id){
  47. parent::__construct($db, null);
  48. $s =
  49. "SELECT " .
  50. " id, " .
  51. " photo, " .
  52. " text, " .
  53. " dtime, " .
  54. " username, " .
  55. " lang, " .
  56. " approved " .
  57. "FROM photo_comment " .
  58. "WHERE id = '$id';";
  59. $q = mysqli_query($this->db, $s);
  60. if (mysqli_num_rows($q) > 0){
  61. $r = mysqli_fetch_array($q);
  62. $this->id = $r["id"];
  63. $this->photo = $r["photo"];
  64. $this->text = $r["text"];
  65. $this->dtime = $r["dtime"];
  66. $this->username = $r["username"];
  67. $this->lang = $r["lang"];
  68. $this->approved = $r["approved"];
  69. }
  70. }
  71. }
  72. ?>