在Controller中,我希望更改实体中的两个值(仅用于索引“3”):
$cle->getVersions()[0]->getLots()[3]->setTantieme(97);
$cle->getVersions()[0]->getLots()[3]->setDateSuppression(new \DateTime);
dump($cle);
$em->flush();但是,只有“坦提姆”的价值发生了变化。我不明白。在我的实体里,我有:
/**
* @var string
*
* @ORM\Column(name="date_suppression", type="datetime", nullable=true)
*/
protected $date_suppression;
public function setDateSuppression($date_suppression)
{
$this->date_suppression = $date_suppression;
}
public function getDateSuppression()
{
return $this->date_supppression;
}--这是的一种特质。而且它对其他实体也很有效。
在刷新前转储结果:图像
坦提姆总是更新,但date_suppression从不.
发布于 2016-01-04 15:26:43
尝试在setDateSuppression()方法中返回“某样东西”:
public function setDateSuppression($date_suppression)
{
$this->date_suppression = $date_suppression;
return $this;
}编辑:
试着这样做:
$cle->getVersions()[0]->getLots()[3]->setDateSuppression(new \DateTime());https://stackoverflow.com/questions/34594347
复制相似问题