qbbr/pgsql-doctrine-random-function

PostgreSQL RANDOM() function for Doctrine ORM

1.0.1 2016-03-12 11:10 UTC

This package is auto-updated.

Last update: 2024-04-14 16:09:48 UTC


README

PostgreSQL RANDOM() function for Doctrine ORM

Latest Stable Version Total Downloads License

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();