Created
October 30, 2011 17:43
-
-
Save Ocramius/1326176 to your computer and use it in GitHub Desktop.
[doctrine-user] Auto create date - annoation - Codeigniter 2 and Doctrine 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$worker = new models\Workers(); | |
$worker->setEmail($data['email']); | |
$this->em->persist($worker); | |
$this->em->flush(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace models; | |
/** | |
* @Entity | |
* @Table(name="workers") | |
* @HasLifecycleCallback | |
*/ | |
class Workers { | |
/** | |
* @Id | |
* @Column(type="integer", nullable=false) | |
* @GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @Column(type="string", length=255, unique=true, nullable=false) | |
*/ | |
protected $email; | |
/** | |
* @var datetime $created_on | |
* | |
* @gedmo:Timestampable(on="create") | |
* @Column(type="datetime") | |
*/ | |
protected $created_on; | |
/** @PrePersist */ | |
function onPrePersist() | |
{ | |
$this->created_on = new \DateTime(); | |
} | |
/* Setters & Getters */ | |
public function setEmail($email){ $this->email = $email; } | |
public function getEmail(){ return $this->email; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment