Ho un campo denominato "compleanno" nell'entità dottrina.Come impostare una data in Doctrine 2?
Vorrei creare un oggetto da aggiungere al database usando doctrine.
all'interno del controller:
$name = "John Alex";
$birthday = "11-11-90";
$student = new Student();
$student->setName($name);
$student->setBirthday(strtotime($birthday);
...
ma quando provo a persistere ottengo questo errore
Fatal error: Call to a member function format() on a non-object in /Library/WebServer/Documents/Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/DateType.php on line 44
Edit:
mia entità:
/**
* @var string $name
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var date $birthday
*
* @ORM\Column(name="birthday", type="date", nullable=true)
*/
private $birthday;
/**
* Set birthday
*
* @param date $birthday
*/
public function setBirthday($birthday)
{
$this->birthday = $birthday;
}
/**
* Get birthday
*
* @return date
*/
public function getBirthday()
{
return $this->birthday;
}
Potrebbe noi il tuo entità ad essa correlata Student mostrare? E hai controllato [questa risposta] (http://stackoverflow.com/questions/7463137/saving-a-zend-date-in-the-database-with-doctrine-2-1)? – j0k
http://pastebin.com/8D7tdSef (non riesco a modificare il thread) –
Hai controllato [questa risposta] (http://stackoverflow.com/questions/7463137/saving-a-zend-date-in- the-database-with-doctrine-2-1)? - su DateTime – j0k