我正在尝试刷新持久化的实体对象,但收到此错误消息:
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
其实这是action方法:
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)));
提前致谢!