PgsqlDoctrineRandomFunction

PostgreSQL RANDOM() function for Doctrine ORM

MIT License

Downloads
85.8K
Stars
4
Committers
1

PgsqlDoctrineRandomFunction

PostgreSQL RANDOM() function for Doctrine ORM

Installation

Step 1: Download the package

$ composer require qbbr/pgsql-doctrine-random-function

Step 2: Configuration

# app/config/config.yml

doctrine:
    orm:
        # ...
        dql:
            numeric_functions:
                Random: Qbbr\PgsqlDoctrineRandomFunction\DQL\RandomFunction

Usage

$em = $this->getDoctrine()->getManager();

$result = $em->createQueryBuilder()
    ->select('e')
    ->from('AppBundle:Entity', 'e')
    ->orderBy('RANDOM()')
    ->setMaxResults(10)
    ->getQuery()
    ->getResult();
Package Rankings
Top 14.39% on Packagist.org
Badges
Extracted from project README
Latest Stable Version Total Downloads License