Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qbbr/pgsqldoctrinerandomfunction
PostgreSQL RANDOM() function for Doctrine ORM
https://github.com/qbbr/pgsqldoctrinerandomfunction
doctrine-orm php postgresql symfony
Last synced: about 1 month ago
JSON representation
PostgreSQL RANDOM() function for Doctrine ORM
- Host: GitHub
- URL: https://github.com/qbbr/pgsqldoctrinerandomfunction
- Owner: qbbr
- License: mit
- Created: 2016-03-11T06:28:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T15:20:41.000Z (11 months ago)
- Last Synced: 2024-03-14T20:20:11.472Z (8 months ago)
- Topics: doctrine-orm, php, postgresql, symfony
- Language: PHP
- Size: 3.91 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PgsqlDoctrineRandomFunction
PostgreSQL RANDOM() function for Doctrine ORM
[![Latest Stable Version](https://poser.pugx.org/qbbr/pgsql-doctrine-random-function/v/stable)](https://packagist.org/packages/qbbr/pgsql-doctrine-random-function)
[![Total Downloads](https://poser.pugx.org/qbbr/pgsql-doctrine-random-function/downloads)](https://packagist.org/packages/qbbr/pgsql-doctrine-random-function)
[![License](https://poser.pugx.org/qbbr/pgsql-doctrine-random-function/license)](https://packagist.org/packages/qbbr/pgsql-doctrine-random-function)## Installation
### Step 1: Download the package
```bash
$ composer require qbbr/pgsql-doctrine-random-function
```### Step 2: Configuration
```yaml
# app/config/config.ymldoctrine:
orm:
# ...
dql:
numeric_functions:
Random: Qbbr\PgsqlDoctrineRandomFunction\DQL\RandomFunction
```## Usage
```php
$em = $this->getDoctrine()->getManager();$result = $em->createQueryBuilder()
->select('e')
->from('AppBundle:Entity', 'e')
->orderBy('RANDOM()')
->setMaxResults(10)
->getQuery()
->getResult();
```