luxifer/doctrine-functions

Doctrine DQL Functions for Mysql

Installs: 97 437

Dependents: 3

Stars: 41

Watchers: 5

Forks: 10

Open Issues: 2

Language: PHP

1.2.5 2015-02-01 12:01 UTC

README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads

This package contains doctrine functions, you can contribute by forking it and propose pull request with your own functions. List of available functions:

  • DATE(expr)
  • DATEDIFF(expr1, expr2)
  • DAYOFWEEK(expr)
  • WEEK(expr)
  • DAY(expr)
  • DAYOFMONTH(expr)
  • DAYOFYEAR(expr)
  • HOUR(expr)
  • MINUTE(expr)
  • MONTH(expr)
  • QUARTER(expr)
  • SECOND(expr)
  • TIME(expr)
  • YEAR(expr)
  • CONVERT_TZ(expr, 'from_tz', 'to_tz') (MySQL implementation ONLY)
  • DATE_FORMAT(expr, 'format') (MySQL ONLY)
  • CONCAT_WS(separator, str1, str2) (MySQL)

Edit this file in your pull request to add your functions to the list.

Installation

Just add the package to your composer.json

{
    "require": {
        "luxifer/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->addCustomDatetimeFunction('date', 'Luxifer\DQL\Datetime\Date');

$em = EntityManager::create($dbParams, $config);

2) Using Symfony 2

With Symfony 2 you can register your functions directly in the config.yml file.

doctrine:
    orm:
        entity_managers:
            default:
                dql:
                    datetime_functions:
                        date:     Luxifer\DQL\Datetime\Date
                        datediff: Luxifer\DQL\Datetime\DateDiff
                        # etc

TODO

  • Make CONCAT_WS extensive (unlimited params)