Skip to content

Commit

Permalink
DQL custom functions on doctrine reference page
Browse files Browse the repository at this point in the history
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
  • Loading branch information
healdropper committed Jun 13, 2014
1 parent b879ad7 commit 2541f86
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions reference/configuration/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2541f86

Please sign in to comment.