Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. namespace SomeBundleEntity;
  2.  
  3. use DoctrineORMMapping as ORM;
  4. use DoctrineCommonCollectionsArrayCollection as ArrayCollection;
  5.  
  6. /**
  7. * @ORMEntity(repositoryClass="SomeBundleEntityRepositoryPostRepository")
  8. * @ORMTable(name="Posts")
  9. */
  10. class Post {
  11. /**
  12. * @ORMId()
  13. * @ORMColumn(name="ID", type="integer")
  14. * @ORMGeneratedValue(strategy="AUTO")
  15. */
  16. protected $ID;
  17.  
  18. /**
  19. * @ORMColumn(name="Title", type="string", length=255, nullable=true)
  20. */
  21. protected $Title;
  22.  
  23. /**
  24. * @ORMColumn(name="Text", type="text", nullable=true)
  25. */
  26. protected $Text;
  27.  
  28. /**
  29. * @ORMColumn(name="Picture", type="string", length=100, nullable=true)
  30. */
  31. protected $Picture;
  32.  
  33. public function __toString() {
  34. return $this->Title;
  35. }
  36.  
  37. public function getID() {
  38. return $this->ID;
  39. }
  40.  
  41. public function getTitle() {
  42. return $this->Title;
  43. }
  44.  
  45. public function setTitle($title) {
  46. $this->Title = $title;
  47.  
  48. return $this;
  49. }
  50.  
  51. public function getText() {
  52. return $this->Text;
  53. }
  54.  
  55. public function setText($text) {
  56. $this->Text = $text;
  57.  
  58. return $this;
  59. }
  60.  
  61. public function getPicture() {
  62. return $this->Picture;
  63. }
  64.  
  65. public function setPicture($picture) {
  66. $this->Picture= $picture;
  67.  
  68. return $this;
  69. }
  70. }
  71.  
  72. public function editAction($ID, Request $request) {
  73. $em = $this->getDoctrine()->getManager();
  74.  
  75. $entity = $em->getRepository("SomeBundle:Post")->find($ID);
  76.  
  77. if (!$entity)
  78. throw $this->createNotFoundException("Unable to find post.");
  79.  
  80. $form = $this->createEditForm($entity);
  81. $form->handleRequest($request);
  82. $this->validateData($form, $entity);
  83.  
  84. if ($form->isValid()) {
  85. $entity->setTitle('Title');
  86. $entity->setPicture('somefilepath');
  87. $em->flush();
  88. }
  89. ...
  90. }
  91.  
  92. UPDATE Posts SET Title = ? WHERE ID = ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement