mmernian / doctrine-timestamp

为 Doctrine ORM 添加时间戳类型的库

1.0 2018-02-24 17:38 UTC

This package is auto-updated.

Last update: 2024-09-25 07:04:13 UTC


README

Doctrine DBAL 的时间戳类型实现

此库将 PHP 的 DateTime 类映射到数据库中的 Unix 时间戳(整数)。

安装

只需将此添加到您的 composer.json 文件中

{
  "require": {
    "mmerian/doctrine-timestamp": "dev-master"
  }
}

然后,在引导 doctrine 连接时

Type::addType('timestamp', 'DoctrineTimestamp\DBAL\Types\Timestamp');
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('Timestamp', 'timestamp');