PHPackages                             durimjusaj/doctrine-extensions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. durimjusaj/doctrine-extensions

ActiveLibrary[Database &amp; ORM](/categories/database)

durimjusaj/doctrine-extensions
==============================

Doctrine Extensions for MySQL and PostgreSQL.

1.0(1y ago)062MITPHPPHP &gt;=8.1

Since Jun 18Pushed 1y agoCompare

[ Source](https://github.com/durimjusaj/doctrine-extensions)[ Packagist](https://packagist.org/packages/durimjusaj/doctrine-extensions)[ Docs](https://github.com/oroinc/doctrine-extensions/)[ RSS](/packages/durimjusaj-doctrine-extensions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Oro Doctrine Extensions
=======================

[](#oro-doctrine-extensions)

[![CI](https://github.com/oroinc/doctrine-extensions/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/oroinc/doctrine-extensions/actions/workflows/ci.yml)

Table of Contents
-----------------

[](#table-of-contents)

- [DQL Functions](#dql-functions-list)
    - [Installation](#installation)
    - [Functions Registration](#functions-registration)
        - [Doctrine2](#doctrine2)
        - [Symfony2](#symfony2)
        - [Silex](#silex)
        - [Zend Framework 2](#zend-framework-2)
    - [Extendability and Database Support](#extendability-and-database-support)
        - [Architecture](#architecture)
        - [Adding new platform](#adding-new-platform)
        - [Adding new function](#adding-new-function)
- [Field Types](#field-types)

DQL Functions
=============

[](#dql-functions)

This library provides a set of Doctrine DQL functions for MySQL and PostgreSQL.

Available functions:

- `DATE(expr)` - Extracts the date part of a date or datetime expression.
- `TIME(expr)` - Extracts the time portion of the provided expression.
- `TIMESTAMP(expr)` - Converts an expression to TIMESTAMP.
- `TIMESTAMPDIFF(unit, datetime_expr1, datetime_expr2)` - Returns *datetime\_expr2* – *datetime\_expr1*, where *datetime\_expr1* and *datetime\_expr2* are date or datetime expressions. The `unit` parameter can take one of the following values: *MICROSECOND* (microseconds), *SECOND*, *MINUTE*, *HOUR*, *DAY*, *WEEK*, *MONTH*, *QUARTER*, or *YEAR*.
- `CONVERT_TZ(expr, from_tz, to_tz)` - Converts a datetime value expr from the time zone given by `from_tz` to the time zone given by `to_tz` and returns the resulting datetime value.
- `DAY(expr)` - Returns the day of the month (0-31).
- `DAYOFWEEK(expr)` - Returns the weekday index (1 = Sunday, 2 = Monday, …, 7 = Saturday) for a date expression. These index values correspond to the ODBC standard.
- `DAYOFMONTH(expr)` - Returns the day of the month for a date expression, in the range 1 to 31, or 0 for dates such as '0000-00-00' or '2008-00-00' that have a zero day part.
- `DAYOFYEAR(expr)` - Returns the day of the year (1-366).
- `HOUR(expr)` - Returns the hour from the argument.
- `MD5(expr)` - Calculates MD5 checksum.
- `MINUTE(expr)` - Returns the minute from the argument.
- `MONTH(expr)` - Returns the month from the date passed.
- `QUARTER(expr)` - Returns the quarter from the date passed.
- `SECOND(expr)` - Returns the second from the argument.
- `WEEK(expr)` - Returns the week number of the year that the day is in. By ISO 8601, weeks start on Monday and the first week of a year contains January 4 of that year. In other words, the first Thursday of a year is in week 1 of that year.
- `YEAR(expr)` - Returns the year from the date passed.
- `POW(expr, power)` - Returns the argument raised to the specified power.
- `ROUND(value, ?precision)` - Rounds the value to the specified precision (defaults to 0 precision if not specified).
- `CEIL(value)` - Returns the value rounded up.
- `SIGN(expr)` - Returns the sign of the argument.
- `CAST(expr as type)` - Takes an expression of any type and produces a result value of a specified type. Supported types are: `char`, `string`, `text`, `date`, `datetime`, `time`, `int`, `integer`, `bigint`, `decimal`, `boolean`, `binary`, `uuid`.
- `CONCAT_WS` - Concatenate all but the first argument. The first argument is used as the separator string.
- `GROUP_CONCAT` - Returns a concatenated string. GROUP\_CONCAT full syntax:

```
GROUP_CONCAT([DISTINCT] expr [,expr ...]
            [ORDER BY {unsigned_integer | col_name | expr}
                [ASC | DESC] [,col_name ...]]
            [SEPARATOR str_val])

```

- `REPLACE(subject, from, to)` - Replaces all occurrences of a string `from` with `to` within a string `subject`.
- `DATE_FORMAT(date, format)` - Formats the date value according to the format string. The following specifiers may be used in the format string (the `%` character is required before format specifier characters):

SpecifierDescription%aAbbreviated weekday name (Sun..Sat)%bAbbreviated month name (Jan..Dec)%cMonth, numeric (0..12)%dDay of the month, numeric (00..31)%eDay of the month, numeric (0..31)%fMicroseconds (000000..999999)%HHour (00..23)%hHour (01..12)%IHour (01..12)%iMinutes, numeric (00..59)%jDay of year (001..366)%kHour (0..23)%lHour (1..12)%MMonth name (January..December)%mMonth, numeric (00..12)%pAM or PM%rTime, 12-hour (hh:mm:ss followed by AM or PM)%SSeconds (00..59)%sSeconds (00..59)%TTime, 24-hour (hh:mm:ss)%WWeekday name (Sunday..Saturday)%YYear, numeric, four digits%yYear, numeric (two digits)%%A literal % characterInstallation
------------

[](#installation)

Add the following dependency to your composer.json:

```
{
    "require": {
        "oro/doctrine-extensions": "^2.0"
    }
}
```

Registering Functions
---------------------

[](#registering-functions)

### Doctrine2

[](#doctrine2)

[Doctrine2 Documentation: "DQL User Defined Functions"](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/cookbook/dql-user-defined-functions.html)

```
