All Projects → mapado → MysqlDoctrineFunctions

mapado / MysqlDoctrineFunctions

Licence: other
MySQL Function for Doctrine : RAND(), ROUND() DATE(), DATE_FORMAT()

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to MysqlDoctrineFunctions

domain
A dependency-free package to help building a business domain layer
Stars: ✭ 33 (-26.67%)
Mutual labels:  doctrine
doctrine-filter
Quickly add advanced filtering/searching and sorting capabilities to any resource in your APIs or Web apps that use Doctrine.
Stars: ✭ 27 (-40%)
Mutual labels:  doctrine
swoole-postgresql-doctrine-driver
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL client
Stars: ✭ 15 (-66.67%)
Mutual labels:  doctrine
php-orm-benchmark
The benchmark to compare performance of PHP ORM solutions.
Stars: ✭ 82 (+82.22%)
Mutual labels:  doctrine
mukadi-wordpress-bundle
Integrate wordpress and symfony in the same application
Stars: ✭ 24 (-46.67%)
Mutual labels:  doctrine
ip
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
Stars: ✭ 212 (+371.11%)
Mutual labels:  doctrine
petstore
A simple skeleton to build api's based on the chubbyphp-framework, mezzio (former zend-expressive) or slim.
Stars: ✭ 34 (-24.44%)
Mutual labels:  doctrine
cart
Domain-Driven Design shop cart demonstration
Stars: ✭ 80 (+77.78%)
Mutual labels:  doctrine
MostGenerator
Transformation cartridges for generating Symfony bundles from ModuleStudio models.
Stars: ✭ 21 (-53.33%)
Mutual labels:  doctrine
doctrine-read-only-hydrator
Add SimpleObject and ReadOnly hydrators do Doctrine.
Stars: ✭ 54 (+20%)
Mutual labels:  doctrine
DoctrineTranslated
Translated strings for Doctrine
Stars: ✭ 12 (-73.33%)
Mutual labels:  doctrine
ErrorHeroModule
💎 A Hero for your Zend Framework/Laminas, and Expressive/Mezzio application to log ( DB and Mail ) and handle php errors & exceptions during Mvc process/between request and response
Stars: ✭ 47 (+4.44%)
Mutual labels:  doctrine
DoctrineMongoODMModule
Laminas Module for Doctrine MongoDB ODM
Stars: ✭ 83 (+84.44%)
Mutual labels:  doctrine
Lumen-Doctrine-DDD-Example
Domain Driven Design Application Example, built with Lumen 5.3 and Doctrine.
Stars: ✭ 72 (+60%)
Mutual labels:  doctrine
phpstan-custom
Specific PHPStan extensions
Stars: ✭ 15 (-66.67%)
Mutual labels:  doctrine
slim-doctrine
Slim-Doctrine managers integration
Stars: ✭ 16 (-64.44%)
Mutual labels:  doctrine
doctrine-active-record
Object-oriented CRUD (create, read, update, delete) for Doctrine DBAL
Stars: ✭ 25 (-44.44%)
Mutual labels:  doctrine
user
A domain layer providing basic user management
Stars: ✭ 14 (-68.89%)
Mutual labels:  doctrine
eav-bundle
A Symfony bundle for basic EAV management
Stars: ✭ 19 (-57.78%)
Mutual labels:  doctrine
doctrine-orm-batcher
No description or website provided.
Stars: ✭ 27 (-40%)
Mutual labels:  doctrine

MySQL Doctrine functions

This library provides you MySQL functions for Doctrine2.

At the moment are supported

  • RAND
  • ROUND
  • DATE
  • DATE_FORMAT

Feel free to fork and add other functions.

Installation

Get the package

With composer

composer require mapado/mysql-doctrine-functions

Add the classes to your configuration

$config = new \Doctrine\ORM\Configuration();
$config->addCustomStringFunction('rand', \Mapado\MysqlDoctrineFunctions\DQL\MysqlRand::class);
$config->addCustomStringFunction('round', \Mapado\MysqlDoctrineFunctions\DQL\MysqlRound::class);
$config->addCustomStringFunction('date', \Mapado\MysqlDoctrineFunctions\DQL\MysqlDate::class);
$config->addCustomStringFunction('date_format', \Mapado\MysqlDoctrineFunctions\DQL\MysqlDateFormat::class);

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

You can of course pick just the functions you need.

Use with Symfony

If you install the library in a Symfony application, you can add this in your config.yml file (doctrine.yaml file if you use symfony flex)

# app/config/config.yml
doctrine:
    orm:
        # ...
        entity_managers:
            default:
                # ...
                dql:
                    numeric_functions:
                        rand:        'Mapado\MysqlDoctrineFunctions\DQL\MysqlRand'
                        round:       'Mapado\MysqlDoctrineFunctions\DQL\MysqlRound'
                    datetime_functions:
                        date:        'Mapado\MysqlDoctrineFunctions\DQL\MysqlDate'
                        date_format: 'Mapado\MysqlDoctrineFunctions\DQL\MysqlDateFormat'
                    # ... add all functions you need

Usage

You can now use the functions in your DQL Query

$query = 'SELECT RAND(), ROUND(123.45) 
        FROM ...
    ';
$em->createQuery($query);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].