[FLOW3-general] Put an entity to the Database with a DateTime property

Patrick Sernetz patrickse at googlemail.com
Tue Aug 9 11:56:07 CEST 2011


Hi Mailinglist,

I´ve just started to work with Flow3 and I am really excited about this
framework. Currently I am trying to create a blog example from scratch. I
really run into a problem with a DateTime field when I try to persist. So
without adding a value to the Timestamp property, everything works fine and
I receive a new entry inside my database. But if I set a value to the
Timestamp property it fails with an log error message...

[Tue Aug 09 11:18:51 2011] [error] [client 127.0.0.1] PHP Fatal error:  Call
to a member function format() on a non-object in
/public_html/FLOW3/Packages/Framework/Doctrine/Classes/DBAL/Types/DateTimeType.php


I really do not know where my problem is. I thought the conversion from
string to datetime works on the fly..

Probably someone from this mailinglist can help me.

Regards,
Patrick

Model
/**
  * @var \DateTime
  */
protected $timestamp;

/**
  * @param \DateTime $timestamp
  * @return void
  */
public function setTimestamp($timestamp) {
     $this->timestamp = $timestamp;
}

/**
  * @return \DateTime
  */
public function getTimestamp() {
    return $this->timestamp;
}



Controller
$post->setTimestamp("1990-01-01");
$this->postRepository->add($post);
$this->flashMessageContainer->add('Successfully posted.');
$this->redirect('index', 'Standard');


More information about the FLOW3-general mailing list