我在学说实体中有一个名为“生日”的字段。
我想创建一个对象以使用教义添加到数据库中。
控制器内部:
$name = "John Alex";
$birthday = "11-11-90";
$student = new Student();
$student->setName($name);
$student->setBirthday(strtotime($birthday);
...
但是当我尝试坚持时,我得到了这个错误
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
编辑:
我的实体:
/**
* @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;
}