Project_Type.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. require_once(PATH::ENTITY . "Entity.php");
  3. /**
  4. * Type of a project.
  5. *
  6. * Represents an object from the table 'project_type'.
  7. */
  8. class Project_Type extends Entity{
  9. /**
  10. * @var int Identifier of the project type.
  11. */
  12. private $id;
  13. /**
  14. * @var String Type denomination, in the defined language.
  15. */
  16. private $title;
  17. /**
  18. * @var String Type description, in the defined language.
  19. */
  20. private $summary;
  21. /**
  22. * Constructor.
  23. *
  24. * Searches the database and retrieves the information about the
  25. * type, populating it.
  26. *
  27. * @param string $id Identifier of the project type.
  28. */
  29. public function __construct($id){
  30. $statement = get_context()->get_db()->prepare("
  31. SELECT
  32. id,
  33. title,
  34. summary
  35. FROM project_type
  36. WHERE id = :id;
  37. ");
  38. $statement->bindValue(':id', $id, PDO::PARAM_INT);
  39. $statement->execute();
  40. $r_type = $statement->fetch(PDO::FETCH_ASSOC);
  41. if ($r_type !== false){
  42. $this->id = $r_type["id"];
  43. $this->title = TEXT::get($r_type["title"]);
  44. $this->summary = TEXT::get($$r_type["summary"]);
  45. $this->mark_as_loaded(true);
  46. $this->mark_as_complete(true);
  47. }
  48. else{
  49. Log::warn("Project type with id '$id' doesn't exist");
  50. }
  51. }
  52. /**
  53. * Retrieves the project type identifier
  54. *
  55. * @return int Project type ID.
  56. */
  57. public function get_id(){
  58. return $this->id;
  59. }
  60. /**
  61. * Retrieves the project type title.
  62. *
  63. * @return string Type name.
  64. */
  65. public function get_title(){
  66. return $this->title;
  67. }
  68. /**
  69. * Retrieves the project type description.
  70. *
  71. * @return string Type summary.
  72. */
  73. public function get_summary(){
  74. return $this->summary;
  75. }
  76. }