herrera-io/dateinterval-bundle

此包已被弃用且不再维护。未建议替代包。

Doctrine 的 DateInterval 库的 Symfony 扩展包。

dev-master / 1.0.x-dev 2013-02-22 00:22 UTC

This package is not auto-updated.

Last update: 2021-12-07 01:33:53 UTC


README

Build Status

Doctrine 的 DateInterval 库的 Symfony 扩展包。

概要

该扩展包将自动

  • 注册 dateinterval Doctrine 映射类型
  • 添加 DATE_INTERVAL DQL 函数

到默认实体管理器(doctrine.orm.entity_manager)。

安装

将其添加到您的 Composer 依赖列表中

$ composer require herrera-io/dateinterval-bundle=1.*

将其添加到您的 app/AppKernel.php 文件中

<?php

public function registerBundles()
{
    $bundles = array(
        // ... snip ...
        new Herrera\Symfony\DateInterval\DateIntervalBundle()
        // ... snip ...
    );
}

使用方法

在实体中

<?php

class MyEntity
{
    /**
     * @ORM\Column(type="dateinterval")
     */
    private $interval;
}

在查询中

SELECT j FROM Jobs j WHERE j.interval < DATE_INTERVAL('PT1H')