qbbr/pgsql-doctrine-random-function

PostgreSQL RANDOM() function for Doctrine ORM

Installs: 108 582

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 2

Open Issues: 2

Type:symfony-bundle

pkg:composer/qbbr/pgsql-doctrine-random-function

1.0.1 2016-03-12 11:10 UTC

This package is auto-updated.

Last update: 2025-09-14 19:04:43 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();