2017 © Pedro Peláez
 

library doctrine-functions

Doctrine DQL Functions for Mysql

image

iakumai/doctrine-functions

Doctrine DQL Functions for Mysql

  • Thursday, January 29, 2015
  • by IAkumaI
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2,508 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

Doctrine Functions

This package contains some doctrine functions, (*1)

String functions

DateTime functions

Math functions

  • RAND() - documentation. Remember, you can not use parameters in this function.
  • RANDP(12345) - documentation. This is still RAND() MySQL function, but you must use a number parameter in it.

Installation

Just add the package to your composer.json, (*2)

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

Integration

1) Doctrine Only

According to the Doctrine documentation you can register the functions in this package this way., (*3)

<?php
$config = new \Doctrine\ORM\Configuration();
$config->addCustomDatetimeFunction('instr', 'IAkumaI\DQL\Str\Instr');
?>

2) Using Symfony 2

With symfony 2 you can register yout functions in the config.yml file., (*4)

doctrine:
    orm:
        entity_managers:
            default:
                dql:
                    datetime_functions:
                        instr: IAkumaI\DQL\Str\Instr

Usage

Simple example, usage a DateFormat function:, (*5)

createQuery("SELECT DATE_FORMAT(e.date, '%d.%m.%Y') as df FROM YourBundle:Ent e");
?>

This way you can use DQL function in ORDER statement. For example, order by RAND():, (*6)

createQuery("SELECT e, RAND() as HIDDEN rand FROM YourBundle:Ent e ORDER BY rand");
?>

The Versions

29/01 2015

dev-master

9999999-dev https://github.com/IAkumaI/doctrine-functions

Doctrine DQL Functions for Mysql

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

by Valery Ozarnichuk

database mysql dql