kspitfire/pgsql-doctrine-round-function

PostgreSQL ROUND() function for Doctrine ORM

Installs: 4 446

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Type:symfony-bundle

1.3 2019-09-08 05:03 UTC

This package is auto-updated.

Last update: 2025-05-08 18:01:03 UTC


README

ROUND() function implementation for Doctrine DQL

Latest Stable Version Total Downloads License

Installation

$ composer require kspitfire/pgsql-doctrine-round-function

Configuration

# app/config/config.yml

doctrine:
    orm:
        # ...
        dql:
            numeric_functions:
                Round: Kspitfire\PgSqlRoundFunction\DQL\RandomFunction

Usage

$em = $this->get('doctrine.orm.default_entity_manager');

// with precision
$resultWithPrecision = $em->getRepository(Entity::class)
    ->createQueryBuilder('e')
    ->select('ROUND(e.fieldName / 15, 2) as num')
    ->setMaxResults(1)
    ->getQuery()
    ->getSingleScalarResult();

// without precision
$resultWithoutPrecision = $em->getRepository(Entity::class)
    ->createQueryBuilder('e')
    ->select('ROUND(e.fieldName / 15) as num')
    ->setMaxResults(1)
    ->getQuery()
    ->getSingleScalarResult();