public function findRandomOneBy(array $criteria)
    {
        $queryBuilder = $this->getQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);

        return $queryBuilder
            ->addSelect('RAND() as HIDDEN rand')
            ->orderBy('rand')
            ->setMaxResults(1)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
public function findRandomOneBy(array $criteria)
    {
        $queryBuilder = $this->getQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);

        return $queryBuilder
            ->addSelect('RAND() as HIDDEN rand')
            ->orderBy('rand')
            ->setMaxResults(1)
            ->getQuery()
            ->getOneOrNullResult()
        ;
    }
public function findRandomOneBy ( array $ criteria ) { $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ this -> applyCriteria ( $ queryBuilder , $ criteria ) ; return $ queryBuilder -> addSelect ( 'RAND() as HIDDEN rand' ) -> orderBy ( 'rand' ) -> setMaxResults ( 1 ) -> getQuery ( ) -> getOneOrNullResult ( ) ; }
Finds a random resource by criteria.

@param array $criteria

@return null|object
Finds a random resource by criteria .