Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SomeBundleEntity;
- use DoctrineORMMapping as ORM;
- use DoctrineCommonCollectionsArrayCollection as ArrayCollection;
- /**
- * @ORMEntity(repositoryClass="SomeBundleEntityRepositoryPostRepository")
- * @ORMTable(name="Posts")
- */
- class Post {
- /**
- * @ORMId()
- * @ORMColumn(name="ID", type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $ID;
- /**
- * @ORMColumn(name="Title", type="string", length=255, nullable=true)
- */
- protected $Title;
- /**
- * @ORMColumn(name="Text", type="text", nullable=true)
- */
- protected $Text;
- /**
- * @ORMColumn(name="Picture", type="string", length=100, nullable=true)
- */
- protected $Picture;
- public function __toString() {
- return $this->Title;
- }
- public function getID() {
- return $this->ID;
- }
- public function getTitle() {
- return $this->Title;
- }
- public function setTitle($title) {
- $this->Title = $title;
- return $this;
- }
- public function getText() {
- return $this->Text;
- }
- public function setText($text) {
- $this->Text = $text;
- return $this;
- }
- public function getPicture() {
- return $this->Picture;
- }
- public function setPicture($picture) {
- $this->Picture= $picture;
- return $this;
- }
- }
- public function editAction($ID, Request $request) {
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository("SomeBundle:Post")->find($ID);
- if (!$entity)
- throw $this->createNotFoundException("Unable to find post.");
- $form = $this->createEditForm($entity);
- $form->handleRequest($request);
- $this->validateData($form, $entity);
- if ($form->isValid()) {
- $entity->setTitle('Title');
- $entity->setPicture('somefilepath');
- $em->flush();
- }
- ...
- }
- UPDATE Posts SET Title = ? WHERE ID = ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement