Skip to content
A set of Doctrine 2 extensions
PHP Makefile
Branch: master
Clone or download

Latest commit

k00ni PHP 7.4 support (#347)
* Added PHP 7.4 to Travis matrix

* Implode deprecation error fix

Related travis error: https://travis-ci.org/beberlei/DoctrineExtensions/jobs/646402791#L389
Latest commit dbd91ed Feb 6, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Oracle CEIL/FLOOR functions + TO_CHAR nlsparam (#336) Dec 4, 2019
src PHP 7.4 support (#347) Feb 6, 2020
tests Fixed exception that is thrown when combining the sqlite CONCAT_WS ex… Dec 5, 2019
.gitattributes add .gitattributes file May 6, 2019
.gitignore PHPUnit 7/8 upgrade May 6, 2019
.php_cs Strip redundant phpdoc May 6, 2019
.travis.yml PHP 7.4 support (#347) Feb 6, 2020
LICENSE License year bump May 15, 2019
Makefile Makefile group fix May 15, 2019
README.md Oracle CEIL/FLOOR functions + TO_CHAR nlsparam (#336) Dec 4, 2019
composer.json Move doctrine/orm to require Jul 11, 2019
phpunit.xml.dist PHPUnit 7/8 upgrade May 6, 2019

README.md

DoctrineExtensions

Build Status Build Status Packagist Packagist Packagist Packagist

A set of extensions to Doctrine 2 that add support for functions available in MySQL, Oracle, PostgreSQL and SQLite.

DB Functions
MySQL ACOS, ADDTIME, AES_DECRYPT, AES_ENCRYPT, ANY_VALUE, ASCII, ASIN, ATAN, ATAN2, BINARY, BIT_COUNT, BIT_XOR, CAST, CEIL, CHAR_LENGTH, COLLATE, CONCAT_WS, CONVERT_TZ, COS, COT, COUNTIF, CRC32, DATE, DATE_FORMAT, DATEADD, DATEDIFF, DATESUB, DAY, DAYNAME, DAYOFWEEK, DAYOFYEAR, DEGREES, DIV, EXP, EXTRACT, FIELD, FIND_IN_SET, FLOOR, FORMAT, FROM_UNIXTIME, GREATEST, GROUP_CONCAT, HEX, HOUR, IFELSE, IFNULL, INET_ATON, INET_NTOA, INET6_ATON, INET6_NTOA, INSTR, IS_IPV4, IS_IPV4_COMPAT, IS_IPV4_MAPPED, IS_IPV6, LAG, LAST_DAY, LEAD, LEAST, LOG, LOG10, LOG2, LPAD, MAKEDATE, MATCH, MD5, MINUTE, MONTH, MONTHNAME, NOW, NULLIF, OVER, PERIOD_DIFF, PI, POWER, QUARTER, RADIANS, RAND, REGEXP, REPLACE, ROUND, RPAD, SECOND, SECTOTIME, SHA1, SHA2, SIN, SOUNDEX, STD, STDDEV, STRTODATE, STR_TO_DATE, SUBSTRING_INDEX, TAN, TIME, TIMEDIFF, TIMESTAMPADD, TIMESTAMPDIFF, TIMETOSEC, UNHEX, UNIX_TIMESTAMP, UTC_TIMESTAMP, UUID_SHORT, VARIANCE, WEEK, WEEKDAY, YEAR, YEARMONTH, YEARWEEK
Oracle CEIL, DAY, FLOOR, LISTAGG, MONTH, NVL, TO_CHAR, TO_DATE, TRUNC, YEAR
Sqlite DATE, MINUTE, HOUR, DAY, WEEK, WEEKDAY, MONTH, YEAR, JULIANDAY, STRFTIME, DATE_FORMAT*, CASE WHEN THEN ELSE END, IFNULL, REPLACE, ROUND
PostgreSQL AT_TIME_ZONE, COUNT_FILTER, DATE_PART, EXTRACT, GREATEST, LEAST, REGEXP_REPLACE, STRING_AGG, TO_CHAR, TO_DATE

Note: Sqlite date functions are implemented as strftime(format, value). Sqlite only supports the most common formats, so date_format will convert the mysql substitutions to the closest available sqlite substitutions. This means date_format(field, '%b %D %Y') -> Jan 1st 2015 becomes strftime('%m %d %Y', field) -> 01 01 2015.

Installation

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:

make test

If you want to run php-cs-fixer:

make fix  # (or make lint for a dry-run)

Usage

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.

Notes

  • MySQL DATE_ADD is available in DQL as DATEADD(CURRENT_DATE(), 1, 'DAY')
  • MySQL DATE_SUB is available in DQL as DATESUB(CURRENT_DATE(), 1, 'DAY')
  • MySQL IF is available in DQL as IFELSE(field > 0, 'true', 'false')

Troubleshooting

Issues are disabled on this repository, if a custom DQL function that you want isn't provided, or does not support the arguments you want to pass, pull requests are open and we would love to have your contributions.

You can’t perform that action at this time.