Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. namespace Acme\ProjectBundle\Entity;
  2.  
  3. use Doctrine\ORM\Mapping as ORM;
  4.  
  5. /**
  6. * @ORM\Entity
  7. * @ORM\HasLifecycleCallbacks
  8. * @ORM\Table(name="projects")
  9. */
  10.  
  11. class Projects
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\Column(type="integer")
  16. * @ORM\GeneratedValue(strategy="AUTO")
  17. */
  18. protected $id;
  19.  
  20. /**
  21. * @ORM\Column(type="string")
  22. */
  23. protected $name;
  24.  
  25. /**
  26. * @ORM\Column(type="datetime")
  27. */
  28. protected $created_at;
  29.  
  30. /**
  31. * @ORM\Column(type="datetime")
  32. */
  33. protected $modified_at;
  34.  
  35. /**
  36. * Now we tell doctrine that before we persist or update we call the updatedTimestamps() function.
  37. *
  38. * @ORM\PrePersist
  39. * @ORM\PreUpdate
  40. */
  41. public function updatedTimestamps()
  42. {
  43. $this->setModifiedAt(new \DateTime(date('Y-m-d H:i:s')));
  44.  
  45. if($this->getCreatedAt() == null)
  46. {
  47. $this->setCreatedAt(new \DateTime(date('Y-m-d H:i:s')));
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement