https://github.com/qbbr/pgsqldoctrinerandomfunction
PostgreSQL RANDOM() function for Doctrine ORM
https://github.com/qbbr/pgsqldoctrinerandomfunction
doctrine-orm php postgresql symfony
Last synced: 6 months 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 (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T16:45:29.000Z (over 1 year ago)
- Last Synced: 2025-06-05T10:49:03.663Z (6 months ago)
- Topics: doctrine-orm, php, postgresql, symfony
- Language: PHP
- Size: 3.91 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PgsqlDoctrineRandomFunction
PostgreSQL RANDOM() function for Doctrine ORM
[](https://packagist.org/packages/qbbr/pgsql-doctrine-random-function)
[](https://packagist.org/packages/qbbr/pgsql-doctrine-random-function)
[](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.yml
doctrine:
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();
```