Som*_*ody 5 php symfony doctrine-orm
https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/working-with-datetime.html
我尝试使用此代码来创建 UTC DateTime 类型。但是,代码没有被调用。
让我困惑的是这一部分:
use Doctrine\DBAL\Types\Type;
use DoctrineExtensions\DBAL\Types\UTCDateTimeType;
Type::overrideType('datetime', UTCDateTimeType::class);
Type::overrideType('datetimetz', UTCDateTimeType::class);
Run Code Online (Sandbox Code Playgroud)
没有解释应该在哪里调用此代码。它只说“在引导 ORM 之前”,经过几个小时的谷歌搜索后我仍然没有弄清楚这意味着什么,我现在陷入了死胡同。
我尝试将代码放在与 UTCDateTimeType 类相同的文件中,但这不起作用。
对于 symfony,新的学说类型应在config/doctrine.yaml文件中声明。
doctrine:
dbal:
types:
datetime: DoctrineExtensions\DBAL\Types\UTCDateTimeType
datetimez: DoctrineExtensions\DBAL\Types\UTCDateTimeType
Run Code Online (Sandbox Code Playgroud)
确保该类DoctrineExtensions\DBAL\Types\UTCDateTimeType存在。
这是安装空间扩展并声明几何类型的完整示例。
| 归档时间: |
|
| 查看次数: |
893 次 |
| 最近记录: |