Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace ProjectEntity;
- use ProjectEntityTraitsIdentifiableTrait;
- use ProjectEntityClient;
- /**
- * This class describes a client.
- */
- class Comment
- {
- use IdentifiableTrait;
- /*
- * @var string
- */
- private $comment;
- /**
- * @var Client
- */
- private $client;
- /**
- * Get /*
- *
- * @return string
- */
- public function getComment()
- {
- return $this->comment;
- }
- /**
- * Set /*
- *
- * @param string $comment /*
- *
- * @return self
- */
- public function setComment($comment)
- {
- $this->comment = $comment;
- return $this;
- }
- /**
- * Get the value of client
- *
- * @return Client
- */
- public function getClient()
- {
- return $this->client;
- }
- /**
- * Set the value of client
- *
- * @param Client $client
- *
- * @return self
- */
- public function setClient(Client $client)
- {
- $this->client = $client;
- return $this;
- }
- }
- ProjectEntityComment:
- type: entity
- table: comments
- id:
- id:
- type: integer
- generator:
- strategy: AUTO
- comment:
- type: text
- column: comment
- nullable: true
- options:
- comment: Client comment.
- oneToOne:
- client:
- targetEntity: ProjectEntityClient
- joinColumn:
- name: id_client
- referenceColumnName: id
- CREATE TABLE `comments` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `id_client` int(11) NOT NULL,
- `comment` longtext COLLATE utf32_spanish_ci,
- PRIMARY KEY (`id`),
- KEY `fk_comments_1_idx` (`id_client`),
- CONSTRAINT `fk_comments_1` FOREIGN KEY (`id_client`) REFERENCES `clients` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
- ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf32 COLLATE=utf32_spanish_ci
- $comment = new Comment();
- $comment->setClient($client)
- ->setComment($this->input->post('comment'));
- $storage->persist($client);
- $storage->persist($comment);
- $storage->flush();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement