Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luxifer/doctrine-functions
📚 Set of DQL Function for MySQL
https://github.com/luxifer/doctrine-functions
doctrine dql-functions mysql php
Last synced: 3 months ago
JSON representation
📚 Set of DQL Function for MySQL
- Host: GitHub
- URL: https://github.com/luxifer/doctrine-functions
- Owner: luxifer
- License: mit
- Created: 2013-05-25T11:34:45.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-12-21T14:06:07.000Z (almost 7 years ago)
- Last Synced: 2024-03-15T15:51:29.300Z (8 months ago)
- Topics: doctrine, dql-functions, mysql, php
- Language: PHP
- Homepage: http://luxifer.github.io/doctrine-functions/
- Size: 236 KB
- Stars: 89
- Watchers: 8
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Doctrine Functions
==================[![Build Status](https://travis-ci.org/luxifer/doctrine-functions.svg?branch=master)](https://travis-ci.org/luxifer/doctrine-functions) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/badges/quality-score.png?s=32406f6c6df4378a2f352bd062707d3c7a0216ea)](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/) [![Code Coverage](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/badges/coverage.png?s=6701d974c062e2c98ec2a556ba8ba4db76667e68)](https://scrutinizer-ci.com/g/luxifer/doctrine-functions/) [![Latest Stable Version](https://poser.pugx.org/luxifer/doctrine-functions/v/stable.png)](https://packagist.org/packages/luxifer/doctrine-functions) [![Total Downloads](https://poser.pugx.org/luxifer/doctrine-functions/downloads.png)](https://packagist.org/packages/luxifer/doctrine-functions)
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)
* `DATE_FORMAT(expr, 'format')` (MySQL)
* `CONCAT_WS(separator, str1, str2, ...)` (MySQL)
* `RAND()` (MySQL)
* `MD5(expr)` (MySQL, Postgres)
* `FROM_UNIXTIME(expr1, expr2)` (MySQL)Edit this file in your pull request to add your functions to the list.
Requirements
------------This library is expected to work with PHP >= 5.3, but you should consider to upgrade to PHP >= 7.0. To contribute to this library you must have PHP >= 7.0 to run the test suite.
Installation
------------Just add the package to your `composer.json`
```json
{
"require": {
"luxifer/doctrine-functions": "^1.5"
}
}
```Integration
-----------### 1) Doctrine Only
According to the [Doctrine documentation](http://doctrine-orm.readthedocs.org/en/latest/cookbook/dql-user-defined-functions.html "Doctrine documentation") you can register the functions in this package this way.
```php
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.
```yaml
doctrine:
orm:
entity_managers:
default:
dql:
datetime_functions:
date: Luxifer\DQL\Datetime\Date
datediff: Luxifer\DQL\Datetime\DateDiff
# etc
```