PHP code example of kspitfire / pgsql-doctrine-round-function
1. Go to this page and download the library: Download kspitfire/pgsql-doctrine-round-function library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kspitfire / pgsql-doctrine-round-function example snippets
$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();