morontt/doctrine-functions

Additional DQL functions for Doctrine2

dev-master 2016-10-14 12:15 UTC

This package is auto-updated.

Last update: 2025-03-29 00:34:41 UTC


README

Additional DQL functions for Doctrine2

Numeric functions

Datetime functions

String functions

  • substr(string, from, count) ref

Installation

Just add the package to your composer.json

{
    "require": {
        "morontt/doctrine-functions": "dev-master"
    }
}

Integration

1) Doctrine Only

According to the Doctrine documentation you can register the functions in this package this way.

<?php
$config = new \Doctrine\ORM\Configuration();
$config->addCustomNumericFunction('rand', 'Morontt\DQL\Numeric\Rand');
?>

2) Using Symfony 2

With symfony 2 you can register you functions in the config.yml file.

doctrine:
    orm:
        entity_managers:
            default:
                dql:
                    numeric_functions:
                        rand: Morontt\DQL\Numeric\Rand
                    datetime_functions:
                        month: Morontt\DQL\DateTime\Month
                    string_functions:
                        substr: Morontt\DQL\String\Substr