public function getQueryBuilder()
    {
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder
            ->select('e')
            ->from($this->admin->getEntityClass(), 'e')
            ->orderBy('e.id', 'DESC');

        $expr = $queryBuilder->expr()->andX();

        /** @var DatagridFilter $filter */
        $i = 0;
        foreach ($this->filters as $filter) {
            $filterExprName = $filter->getExpression();
            // Value can be false but valid, it is only invalid when null.
            if ($filterExprName && !is_null($filter->getValue())) {
                $filterExpr = $queryBuilder->expr()->{$filterExprName}('e.'.$filter->getName(), ':param_'.$i);
                $queryBuilder->setParameter('param_'.$i, $filter->getValue());
                $expr->add($filterExpr);
                $i++;
            }
        }

        if ($expr->count() > 0) {
            $queryBuilder->where($expr);
        }

        return $queryBuilder;
    }
public function getQueryBuilder()
    {
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder
            ->select('e')
            ->from($this->admin->getEntityClass(), 'e')
            ->orderBy('e.id', 'DESC');

        $expr = $queryBuilder->expr()->andX();

        /** @var DatagridFilter $filter */
        $i = 0;
        foreach ($this->filters as $filter) {
            $filterExprName = $filter->getExpression();
            // Value can be false but valid, it is only invalid when null.
            if ($filterExprName && !is_null($filter->getValue())) {
                $filterExpr = $queryBuilder->expr()->{$filterExprName}('e.'.$filter->getName(), ':param_'.$i);
                $queryBuilder->setParameter('param_'.$i, $filter->getValue());
                $expr->add($filterExpr);
                $i++;
            }
        }

        if ($expr->count() > 0) {
            $queryBuilder->where($expr);
        }

        return $queryBuilder;
    }
public function getQueryBuilder ( ) { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'e' ) -> from ( $ this -> admin -> getEntityClass ( ) , 'e' ) -> orderBy ( 'e.id' , 'DESC' ) ; $ expr = $ queryBuilder -> expr ( ) -> andX ( ) ; /** @var DatagridFilter $filter */ $ i = 0 ; foreach ( $ this -> filters as $ filter ) { $ filterExprName = $ filter -> getExpression ( ) ; // Value can be false but valid, it is only invalid when null. if ( $ filterExprName && ! is_null ( $ filter -> getValue ( ) ) ) { $ filterExpr = $ queryBuilder -> expr ( ) -> { $ filterExprName } ( 'e.' . $ filter -> getName ( ) , ':param_' . $ i ) ; $ queryBuilder -> setParameter ( 'param_' . $ i , $ filter -> getValue ( ) ) ; $ expr -> add ( $ filterExpr ) ; $ i ++ ; } } if ( $ expr -> count ( ) > 0 ) { $ queryBuilder -> where ( $ expr ) ; } return $ queryBuilder ; }
Get QueryBuilder to populate Datagrid

@return \Doctrine\ORM\QueryBuilder;
Get QueryBuilder to populate Datagrid