Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <?php
  2.  
  3. namespace ProjectEntity;
  4.  
  5. use ProjectEntityTraitsIdentifiableTrait;
  6. use ProjectEntityClient;
  7.  
  8. /**
  9. * This class describes a client.
  10. */
  11. class Comment
  12. {
  13. use IdentifiableTrait;
  14.  
  15.  
  16.  
  17. /*
  18. * @var string
  19. */
  20. private $comment;
  21. /**
  22. * @var Client
  23. */
  24. private $client;
  25.  
  26.  
  27. /**
  28. * Get /*
  29. *
  30. * @return string
  31. */
  32. public function getComment()
  33. {
  34. return $this->comment;
  35. }
  36.  
  37. /**
  38. * Set /*
  39. *
  40. * @param string $comment /*
  41. *
  42. * @return self
  43. */
  44.  
  45. public function setComment($comment)
  46. {
  47. $this->comment = $comment;
  48.  
  49. return $this;
  50. }
  51.  
  52. /**
  53. * Get the value of client
  54. *
  55. * @return Client
  56. */
  57. public function getClient()
  58. {
  59. return $this->client;
  60. }
  61.  
  62. /**
  63. * Set the value of client
  64. *
  65. * @param Client $client
  66. *
  67. * @return self
  68. */
  69. public function setClient(Client $client)
  70. {
  71. $this->client = $client;
  72.  
  73. return $this;
  74. }
  75. }
  76.  
  77. ProjectEntityComment:
  78. type: entity
  79. table: comments
  80.  
  81. id:
  82. id:
  83. type: integer
  84. generator:
  85. strategy: AUTO
  86.  
  87. comment:
  88. type: text
  89. column: comment
  90. nullable: true
  91. options:
  92. comment: Client comment.
  93.  
  94. oneToOne:
  95. client:
  96. targetEntity: ProjectEntityClient
  97. joinColumn:
  98. name: id_client
  99. referenceColumnName: id
  100.  
  101. CREATE TABLE `comments` (
  102. `id` int(11) NOT NULL AUTO_INCREMENT,
  103. `id_client` int(11) NOT NULL,
  104. `comment` longtext COLLATE utf32_spanish_ci,
  105. PRIMARY KEY (`id`),
  106. KEY `fk_comments_1_idx` (`id_client`),
  107. CONSTRAINT `fk_comments_1` FOREIGN KEY (`id_client`) REFERENCES `clients` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
  108. ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf32 COLLATE=utf32_spanish_ci
  109.  
  110. $comment = new Comment();
  111. $comment->setClient($client)
  112. ->setComment($this->input->post('comment'));
  113. $storage->persist($client);
  114. $storage->persist($comment);
  115. $storage->flush();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement