2017 © Pedro Peláez
 

library mysql-functions-doctrine2

MySQL Function for Doctrine : CONCAT_WS

image

glauberkyves/mysql-functions-doctrine2

MySQL Function for Doctrine : CONCAT_WS

  • Tuesday, September 15, 2015
  • by glauberkyves
  • Repository
  • 2 Watchers
  • 0 Stars
  • 1,561 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

MySQL functions Doctrine2

This library provides you MySQL functions for Doctrine2., (*1)

At the moment are supported, (*2)

  • CONCAT_WS
  • GEO
  • DATE
  • YEAR
  • MONTH
  • DAY

Feel free to fork and add other functions., (*3)

Installation

Get the bundle

Add this in your composer.json, (*4)

{
    "require": {
        "glauberkyves/mysql-functions-doctrine2": "1.*"
    }
}

and then run, (*5)

php composer.phar update

or, (*6)

composer update

if you installed composer globally., (*7)

Add the classes to your configuration

$config = new \Doctrine\ORM\Configuration();
$config->addCustomStringFunction('concat_ws', 'GlauberKyves\MysqlDoctrineFunctions\DQL\MysqlRand');

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

You can of course pick just the functions you need., (*8)

Use with Symfony2

If you install the library in a Symfony2 application, you can add this in your config.yml, (*9)

# app/config/config.yml
doctrine:
    orm:
        # ...
        entity_managers:
            default:
                # ...
                dql:
                    string_functions:
                        concat_ws: GlauberKyves\MysqlDoctrineFunctions\DQL\MysqlConcatWs
                        month: GlauberKyves\MysqlDoctrineFunctions\DQL\MysqlMonth
                    numeric_functions:
                        geo: GlauberKyves\MysqlDoctrineFunctions\DQL\MysqlGeo
                    datetime_functions:
                        date: GlauberKyves\MysqlDoctrineFunctions\DQL\MysqlDate
                        day: GlauberKyves\MysqlDoctrineFunctions\DQL\MysqlDay
                        year: GlauberKyves\MysqlDoctrineFunctions\DQL\MysqlYear

Usage

You can now use the functions in your DQL Query, (*10)

$query = 'SELECT CONCAT_WS('string', 'string') FROM ...';
$em->createQuery($query);

$query = 'SELECT GEO(-15.5656, -47.5656, t.latitude, t.longitude) FROM tb_address t ...';
$em->createQuery($query);

The Versions

15/09 2015

dev-master

9999999-dev

MySQL Function for Doctrine : CONCAT_WS

  Sources   Download

MIT

The Requires

 

by Glauber Kyves

function doctrine mysql glauberkyves

07/02 2015

0.1.0

0.1.0.0

MySQL Function for Doctrine : CONCAT_WS

  Sources   Download

MIT

The Requires

 

by Glauber Kyves

function doctrine mysql glauberkyves