如何在Doctrine2中的日期列中插入/更新空值?
我已将日期列设置为nullable = true.
/**
* @ORM\Column(type="date", nullable=true)
*/
private $dateBar;
Run Code Online (Sandbox Code Playgroud)
我试过这个:
$foo->setDateBar(new \DateTime()); // Inserts today's date
$foo->setDateBar(); // Throws error
Run Code Online (Sandbox Code Playgroud)
我在doctrine2的文档中找不到任何内容.
我猜你的setDateBar总是需要一个参数?尝试:
public function setDateBar($date = null)
{
$this->dateBar = $date;
}
Run Code Online (Sandbox Code Playgroud)
如果这不是问题,那么请发布您的错误消息.
| 归档时间: |
|
| 查看次数: |
3951 次 |
| 最近记录: |