Last Updated: February 25, 2016
· stefanosala

Add a HIDDEN select column to Doctrine query builder

Just add HIDDEN keyword to select:

namespace Acme\FooBundle\Repository;

use Doctrine\ORM\EntityRepository;

class FooRepository extends EntityRepository
    public function findRandom($number)
        return $this->createQueryBuilder('q')
            ->select('q, RAND() as HIDDEN r')

1 Response
Add your response

Yeah, I know RAND() is not the best way to select random rows :)

over 1 year ago ·