Doctrine 日期间隔库的 Symfony 扩展包。

dev-master / 1.0.x-dev 2016-02-04 09:18 UTC

This package is not auto-updated.

Last update: 2024-09-20 09:31:45 UTC


README

Build Status

Doctrine 日期间隔库的 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')