From 2541f863ce80c8ea23e45ad187b14ba57dbcf254 Mon Sep 17 00:00:00 2001 From: healdropper Date: Fri, 13 Jun 2014 14:09:25 +0200 Subject: [PATCH] DQL custom functions on doctrine reference page Seems that there is two possibilities to configure custom DQL functions It should be clearified in doctrine reference page because It may confuse some people if they just read the cookbook: http://symfony.com/doc/current/cookbook/doctrine/custom_dql_functions.html --- reference/configuration/doctrine.rst | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index 9c9b959123a..13b97c56f81 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -411,3 +411,42 @@ Each connection is also accessible via the ``doctrine.dbal.[name]_connection`` service where ``[name]`` is the name of the connection. .. _DBAL documentation: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html + +Register Custom DQL Functions +----------------------------- + +Doctrine allows you to specify custom DQL functions. For more information +on this topic, read Doctrine's cookbook article "`DQL User Defined Functions`_". + +In Symfony, you can register your custom DQL functions as follows: + +.. code-block:: yaml + doctrine: + orm: + # ... + entity_managers: + default: + # ... + dql: + string_functions: + test_string: Acme\HelloBundle\DQL\StringFunction + second_string: Acme\HelloBundle\DQL\SecondStringFunction + numeric_functions: + test_numeric: Acme\HelloBundle\DQL\NumericFunction + datetime_functions: + test_datetime: Acme\HelloBundle\DQL\DatetimeFunction + +However, if you are only using one entity manager, DQL functions can be registed like this: + +.. code-block:: yaml + doctrine: + orm: + # ... + dql: + string_functions: + test_string: Acme\HelloBundle\DQL\StringFunction + second_string: Acme\HelloBundle\DQL\SecondStringFunction + numeric_functions: + test_numeric: Acme\HelloBundle\DQL\NumericFunction + datetime_functions: + test_datetime: Acme\HelloBundle\DQL\DatetimeFunction