Код: Выделить всё
Doctrine\DBAL\Types\Exception\InvalidType: Could not convert PHP value of type DateTimeImmutable to type Doctrine\DBAL\Types\DateTimeType. Expected one of the following types: null, DateTime.
Код: Выделить всё
$accountstatement->setAccountStatementCreatedOn(new \DateTimeImmutable());
$em->persist($accountstatement);
$em->flush();
Код: Выделить всё
#[ORM\Column(type: 'datetime')]
private $AccountStatement_CreatedOn;
.
.
.
public function getAccountStatementCreatedOn(): ?\DateTimeInterface
{
return $this->AccountStatement_CreatedOn;
}
public function setAccountStatementCreatedOn(\DateTimeInterface $AccountStatement_CreatedOn): self
{
$this->AccountStatement_CreatedOn = $AccountStatement_CreatedOn;
return $this;
}
Symfony: 6.4.9
PHP: 8.1.2-1ubuntu2.18
doctrine/dbal 4.0.4
doctrine/deprecations 1.1.3
doctrine/doctrine-bundle 2.12.0
doctrine/doctrine-fixtures-bundle 3.6.1
doctrine/doctrine-migrations-bundle 3.3.1
doctrine/event-manager 2.0.1
doctrine/inflector 2.0.10
doctrine/instantiator 2.0.0
doctrine/lexer 3.0.1
doctrine/migrations 3.8.0
doctrine/orm 3.2.1
mysql, версия 15.1 Распространение 10.6.18-MariaDB
Есть несколько вопросов по Stackoverflow с похожей проблемой, но основные причины в этих случаях разные и, следовательно, не решают мою проблему. Интересно, сможет ли кто-нибудь указать, что может быть не так?
Подробнее здесь: https://stackoverflow.com/questions/787 ... -dbal-type
Мобильная версия