.. index:: single: Doctrine; Custom DQL functions How to 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: .. configuration-block:: .. code-block:: yaml # app/config/config.yml 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 .. code-block:: xml Acme\HelloBundle\DQL\SecondStringFunction Acme\HelloBundle\DQL\DatetimeFunction .. code-block:: php // app/config/config.php $container->loadFromExtension('doctrine', array( 'orm' => array( // ... 'entity_managers' => array( 'default' => array( // ... 'dql' => array( 'string_functions' => array( 'test_string' => 'Acme\HelloBundle\DQL\StringFunction', 'second_string' => 'Acme\HelloBundle\DQL\SecondStringFunction', ), 'numeric_functions' => array( 'test_numeric' => 'Acme\HelloBundle\DQL\NumericFunction', ), 'datetime_functions' => array( 'test_datetime' => 'Acme\HelloBundle\DQL\DatetimeFunction', ), ), ), ), ), )); .. _`DQL User Defined Functions`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/dql-user-defined-functions.html