Doctrine

DQLFonctions

Les fonctions suivantes sont prises en charge dans les clauses SELECT, WHERE et HAVING :

  • IDENTITY(single\_association\_path\_expression [, fieldMapping]) - Retrouvez la colonne clé étrangère de l'association du côté propriétaire
  • ABS(arithmetic\_expression)
  • CONCAT(str1, str2)
  • CURRENT\_DATE() - Return the current date
  • CURRENT\_TIME() - Returns the current time
  • CURRENT\_TIMESTAMP() - Returns a timestamp of the current date and time.
  • LENGTH(str) - Returns the length of the given string
  • LOCATE(needle, haystack [, offset]) - Locate the first occurrence of the substring in the string.
  • LOWER(str) - returns the string lowercased.
  • MOD(a, b) - Return a MOD b.
  • SIZE(collection) - Return the number of elements in the specified collection
  • SQRT(q) - Return the square-root of q.
  • SUBSTRING(str, start [, length]) - Return substring of given string.
  • TRIM([LEADING \ BOTH] ['trchar' FROM] str) - Trim the string by the given trim char, defaults to whitespaces.
  • UPPER(str) - Return the upper-case of the given string.
  • DATE_ADD(date, days, unit) - Add the number of days to a given date. (Supported units are DAY, MONTH)
  • DATE_SUB(date, days, unit) - Substract the number of days from a given date. (Supported units are DAY, MONTH)
  • DATE_DIFF(date1, date2) - Calculate the difference in days between date1-date2.

 

https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/dql-doctrine-query-language.html

Extensions

config\packages\doctrine.yaml

 

dql:
    datetime_functions:
        date_format: DoctrineExtensions\Query\Mysql\DateFormat
        now: DoctrineExtensions\Query\Mysql\Now
        datesub: DoctrineExtensions\Query\Mysql\DateSub

        year: DoctrineExtensions\Query\Mysql\Year
        month: DoctrineExtensions\Query\Mysql\Month

 

https://symfony.com/doc/current/doctrine/custom_dql_functions.html