我正在尝试刷新一个持久的实体对象,但我收到此错误消息:
Fatal error: Call to a member function format() on a non-object in C:\xampp\htdocs\project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Types\DateType.php on line 44
实际上这是行动方法:
public function processRegisterFormAction()
{
$data = filter_var_array($_POST['form'], FILTER_SANITIZE_STRING);
extract($data);
$customer = new Customer();
$dob = explode('/', $date_of_birth);
$date_of_birth = $dob[2] . '-' . $dob[1] . '-' . $dob[0];
$datetime = date('Y-m-d H:i:s');
$customer->setEmail($email);
$customer->setPassword($password);
$customer->setName($name);
$customer->setGender($gender);
$customer->setDateOfBirth($date_of_birth);
$customer->setZipcode($zipcode);
$customer->setState($state);
$customer->setCity($city);
$customer->setDistrict($district);
$customer->setAddress($address);
$customer->setStreetNumber($street_number);
$customer->setCompanyName($company_name);
$customer->setCreated( $datetime);
$customer->setLastModified($datetime);
$em = $this->getDoctrine()->getManager();
$em->persist($customer);
$em->flush();
return new Response('Created Customer ' . $customer->getId() );
}
在我的实体中,我已声明$ dateOfBirth,$ created,$ lastModified为" String"因为我认为这是与日期时间有关的东西,但是,没有!
我倾销了$ em-> persist($ customer)它返回NULL
die(var_dump($em->persist($customer)));
提前致谢!