カスタム DQL 関数の登録方法 ================================ Doctrine はカスタム DQL 関数をサポートしています。詳細は、 Doctrine のクックブックの記事 "`DQL User Defined Functions`_" を参照してください。 Symfony で、カスタム DQL 関数の登録をする際には、以下のようになります。 .. 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://www.doctrine-project.org/docs/orm/2.0/en/cookbook/dql-user-defined-functions.html .. 2011/11/01 ganchiku 66cf47dcaf8d506111a3d242f5c0ede2c87134e7