A set of extensions to Doctrine 2 that add support for functions available in MySQL, Oracle, PostgreSQL and SQLite.
Note: Sqlite date functions are implemented as
strftime(format, value). Sqlite only supports the most common formats, so
date_formatwill convert the mysql substitutions to the closest available sqlite substitutions. This means
date_format(field, '%b %D %Y') -> Jan 1st 2015becomes
strftime('%m %d %Y', field) -> 01 01 2015.
To install this library, run the command below and you will get the latest version:
composer require beberlei/doctrineextensions
If you want to run phpunit:
If you want to run php-cs-fixer:
make fix # (or make lint for a dry-run)
If you are using DoctrineExtensions with Symfony read How to Register custom DQL Functions.
You can find example Symfony configuration for using DoctrineExtensions custom DQL functions in config.
If you are using DoctrineExtensions standalone, you might want to fire up the autoloader:
<?php $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', '/path/to/extensions'); $classLoader->register();
For more information check out the documentation of Doctrine DQL User Defined Functions.
DATE_ADDis available in DQL as
DATEADD(CURRENT_DATE(), 1, 'DAY')
DATE_SUBis available in DQL as
DATESUB(CURRENT_DATE(), 1, 'DAY')
IFis available in DQL as
IFELSE(field > 0, 'true', 'false')
Issues are now disabled on this repository, they were mostly being abused for feature requests that would never be serviced, if a custom DQL function that you want isn't provided, or does not support the arguments you want to pass – then it's up to you to solve that problem and if you want to contribute that back in the form of a pull request we would love to have it.