'DateTime being persisted to one DB column but not the other in Symfony 4.4 app
I have a baffling issues where I have a DateTime
object which seems to be able to be persisted and flushed to one column, but not the other.
I have checked the DB, the data isn't be written to the "protectiondate" column.
$lifecycle->setRemovalDate($extendedProtectionDate); // this line works
$lifecycle->setProtectionDate($extendedProtectionDate); // this line doesn't
$em = $this->doctrine->getManager();
$em->persist($lifecycle);
$em->flush();
The fields are defined identically:
/**
* @var DateTime
*
* @ORM\Column(name="removalDate", type="date", nullable=true)
*/
private $removalDate;
/**
* @var DateTime
*
* @ORM\Column(name="protectionDate", type="date", nullable=true)
*/
private $protectionDate;
As are the accessors and mutators:
/**
* @param DateTime|null $removalDate
*
* @return Lifecycle
*/
public function setRemovalDate($removalDate = null) : self
{
$this->removalDate = $removalDate;
return $this;
}
/**
* @return DateTime|null
*/
public function getRemovalDate() : ?DateTime
{
return $this->removalDate;
}
/**
* @param DateTime|null $protectionDate
*
* @return Lifecycle
*/
public function setProtectionDate($protectionDate = null) : self
{
$this->protectionDate = $protectionDate;
return $this;
}
/**
* @return DateTime|null
*/
public function getProtectionDate() : ?DateTime
{
return $this->protectionDate;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|