我需要帮助。所以,我想添加时间类型的行。我有以下代码。 实体maper xml:
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping>
<entity name="Entity\Facility" table="facility">
<id name="_id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="_time_open" column="time_open" type="time"/>
<field name="_time_close" column="time_close" type="time"/>
</entity>
</doctrine-mapping>
这是我的班级:
class Facility extends AbstractEntity {
private $_time_open;
private $_time_close;
public function setTimeOpen($timeOpen) {
$this->_time_open = $timeOpen;
return $this;
}
public function setTimeClose($timeClose) {
$this->_time_close = $timeClose;
return $this;
}
public function getTimeOpen() {
return $this->_time_open;
}
public function getTimeClose() {
return $this->_time_close;
}
}
如何添加时间类型的行? 我试着用这种方式:
$facility->setTimeOpen(new DataTime()->format('h:i:s');