[FLOW3-general] Storing default values or properties into database
Nkongme
pss93 at gmx.de
Fri Nov 11 12:48:14 CET 2011
Hi guys,
I would like to use the model below to automatically store a timestamp
into the database when a user object is created and persisted. When I
use the code below, the property/field "registrationdate" is always
stored with the value 0000-00-00 00:00:00 and not the actual date. What
am I doing wrong?
use Doctrine\ORM\Mapping as ORM;
use TYPO3\FLOW3\Annotations as FLOW3;
/**
* A User
*
* @FLOW3\Scope prototype
* @FLOW3\Entity
*/
class User {
/**
* The name
* @var string
*/
protected $name;
/**
* @var \DateTime
* @ORM\Column(type="datetime")
*/
protected $registrationdate;
/**
* Constructs this user
*/
public function __construct() {
$this->registrationdate = new \DateTime();
}
/**
* Get the User's name
*
* @return string The User's name
*/
public function getName() {
return $this->name;
}
/**
* Sets this User's name
*
* @param string $name The User's name
* @return void
*/
public function setName($name) {
$this->name = $name;
}
}
I would appreciate any suggestions. Thanks!
Ed
More information about the FLOW3-general
mailing list