nanaweb / doctrine-date-function-extension
Installs: 8 159
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- doctrine/orm: >=2.4
Requires (Dev)
- php: >=8.0.0
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-11-10 19:20:34 UTC
README
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