morontt/doctrine-functions

Additional DQL functions for Doctrine2

Installs: 2 957

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/morontt/doctrine-functions

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

This package is auto-updated.

Last update: 2025-09-29 01:38:33 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