nanaweb/doctrine-date-function-extension

v0.9.2 2022-05-10 14:02 UTC

This package is auto-updated.

Last update: 2024-12-10 19:26:20 UTC


README

Build Status

install

via composer

$ composer require nanaweb/doctrine-date-function-extension:dev-master@dev

usage

NOTE: If your app is based on SQLite, please change namespaces below from "MySql" to "SQLite3".

Doctrine

$config = new \Doctrine\ORM\Configuration();
$config->addCustomDatetimeFunction('month', '\Nanaweb\Doctrine\DateFunctionExtension\MySql\Month');
$config->addCustomDatetimeFunction('weekday', '\Nanaweb\Doctrine\DateFunctionExtension\MySql\Weekday');
$config->addCustomDatetimeFunction('year', '\Nanaweb\Doctrine\DateFunctionExtension\MySql\Year');
$config->addCustomDatetimeFunction('weekofyear', '\Nanaweb\Doctrine\DateFunctionExtension\MySql\WeekOfYear');

$em = EntityManager::create($dbParams, $config);

Symfony2

Configure functions in config.yml.

    orm:
        # ...
        entity_managers:
            default:
                # ...
                dql:
                    datetime_functions:
                        month: \Nanaweb\Doctrine\DateFunctionExtension\MySql\Month
                        weekday: \Nanaweb\Doctrine\DateFunctionExtension\MySql\Weekday
                        year: \Nanaweb\Doctrine\DateFunctionExtension\MySql\Year
                        weekofyear: \Nanaweb\Doctrine\DateFunctionExtension\MySql\WeekOfYear