Build a query builder "Count filtered".

@param DataTablesWrapperInterface $dtWrapper The wrapper.
@return QueryBuilder Returns the query builder "Count filtered".
770574
protected function buildDataTablesCountFiltered(DataTablesWrapperInterface $dtWrapper) {

        $prefix = $dtWrapper->getMapping()->getPrefix();

        $qb = $this->createQueryBuilder($prefix)
            ->select("COUNT(" . $prefix . ")");

        DataTablesRepositoryHelper::appendWhere($qb, $dtWrapper);

        return $qb;
    }
1243066
public static long count_filtered(nitro_service service, String servicename, filtervalue[] filter) throws Exception{
		gslbservice_dnsview_binding obj = new gslbservice_dnsview_binding();
		obj.set_servicename(servicename);
		options option = new options();
		option.set_count(true);
		option.set_filter(filter);
		gslbservice_dnsview_binding[] response = (gslbservice_dnsview_binding[]) obj.getfiltered(service, option);
		if (response != null) {
			return response[0].__count;
		}
		return 0;
	}
646872
public static function determineOperator(DataTablesWrapperInterface $dtWrapper) {

        foreach ($dtWrapper->getRequest()->getColumns() as $dtColumn) {
            if (false === $dtColumn->getSearchable()) {
                continue;
            }
            if ("" !== $dtColumn->getSearch()->getValue()) {
                return "AND";
            }
        }

        // Check if the wrapper defines a search.
        if ("" !== $dtWrapper->getRequest()->getSearch()->getValue()) {
            return "OR";
        }

        return null;
    }
650319
public static function parseWrapper(DataTablesWrapperInterface $wrapper, Request $request) {
        $wrapper->setRequest(static::parseRequest($wrapper, $request));
        $wrapper->setResponse(static::newResponse($wrapper));
    }
454513
public static function appendWhere(QueryBuilder $queryBuilder, DataTablesWrapperInterface $dtWrapper) {

        $operator = static::determineOperator($dtWrapper);
        if (null === $operator) {
            return;
        }

        $wheres = [];
        $params = [];
        $values = [];

        foreach ($dtWrapper->getRequest()->getColumns() as $dtColumn) {

            if (true === $dtColumn->getSearchable() && ("OR" === $operator || "" !== $dtColumn->getSearch()->getValue())) {

                $wheres[] = DataTablesMappingHelper::getWhere($dtColumn->getMapping());
                $params[] = DataTablesMappingHelper::getParam($dtColumn->getMapping());
                $values[] = "%" . ("AND" === $operator ? $dtColumn->getSearch()->getValue() : $dtWrapper->getRequest()->getSearch()->getValue()) . "%";
            }
        }

        $queryBuilder->andWhere("(" . implode(" " . $operator . " ", $wheres) . ")");
        for ($i = count($params) - 1; 0 <= $i; --$i) {
            $queryBuilder->setParameter($params[$i], $values[$i]);
        }
    }
990689
public function _getFilteredQueriesIterator($wpdb = null)
    {
        if (null === $wpdb) {
            $wpdb = $this->getWpdbInstance();
        }

        $queriesArrayIterator = new \ArrayIterator($wpdb->queries);
        $filteredQueriesIterator = new SetupTearDownQueriesFilter(new FactoryQueriesFilter($queriesArrayIterator));

        return $filteredQueriesIterator;
    }
574578
protected static function parseColumn(array $rawColumn, DataTablesWrapperInterface $wrapper) {

        if (false === static::isValidRawColumn($rawColumn)) {
            return null;
        }

        $dtColumn = $wrapper->getColumn($rawColumn[DataTablesColumnInterface::DATATABLES_PARAMETER_DATA]);
        if (null === $dtColumn) {
            return null;
        }
        if ($dtColumn->getName() !== $rawColumn[DataTablesColumnInterface::DATATABLES_PARAMETER_NAME]) {
            return null;
        }
        if (false === $dtColumn->getSearchable()) {
            $dtColumn->setSearch(static::parseSearch([])); // Set a default search.
            return $dtColumn;
        }

        $dtColumn->setSearch(static::parseSearch($rawColumn[DataTablesColumnInterface::DATATABLES_PARAMETER_SEARCH]));

        return $dtColumn;
    }
1060375
protected FilterInstanceWrapper createFilterInstanceWrapper (String filterName, Filter filter, ManagedObject mo) throws InjectionException{ //596191 updated signature
        return new FilterInstanceWrapper(filterName, filter, _evtSource, mo);
    }
35985
public static long count_filtered(nitro_service service, lbmonbindings obj, String filter) throws Exception{
		options option = new options();
		option.set_count(true);
		option.set_filter(filter);
		option.set_args(nitro_util.object_to_string_withoutquotes(obj));
		lbmonbindings[] response = (lbmonbindings[]) obj.getfiltered(service, option);
		if (response != null) {
			return response[0].__count;
		}
		return 0;
	}
1002313
protected function exportDataTablesCallback(DataTablesProviderInterface $dtProvider, DataTablesRepositoryInterface $repository, DataTablesCSVExporterInterface $dtExporter, $windows) {

        $em = $this->getDoctrine()->getManager();

        $stream = fopen("php://output", "w+");

        // Export the columns.
        fputcsv($stream, DataTablesExportHelper::convert($dtExporter->exportColumns(), $windows), ";");

        // Paginates.
        $total = $repository->dataTablesCountExported($dtProvider);
        $pages = PaginateHelper::getPagesCount($total, DataTablesRepositoryInterface::REPOSITORY_LIMIT);

        // Handle each page.
        for ($i = 0; $i < $pages; ++$i) {

            // Get the offset and limit.
            list($offset, $limit) = PaginateHelper::getPageOffsetAndLimit($i, DataTablesRepositoryInterface::REPOSITORY_LIMIT, $total);

            // Get the export query with offset and limit.
            $result = $repository->dataTablesExportAll($dtProvider)
                ->setFirstResult($offset)
                ->setMaxResults($limit)
                ->getQuery()
                ->iterate();

            while (false !== ($row = $result->next())) {

                $this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_EXPORT, [$row[0]]);

                fputcsv($stream, DataTablesExportHelper::convert($dtExporter->exportRow($row[0]), $windows), ";");

                // Detach the entity to avoid memory consumption.
                $em->detach($row[0]);

                $this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_EXPORT, [$row[0]]);
            }
        }

        // Close the file.
        fclose($stream);
    }
550831
public function _UpdateQueryBuilder(Builder $objBuilder)
    {
        $intLength = count($this->objNodeArray);
        for ($intIndex = 0; $intIndex < $intLength; $intIndex++) {
            $objNode = $this->objNodeArray[$intIndex];
            if ($objNode instanceof Node\Virtual) {
                if ($objNode->hasSubquery()) {
                    throw new Caller('You cannot define a virtual node in an order by clause. You must use an Expand clause to define it.');
                }
                $strOrderByCommand = '__' . $objNode->getAttributeName();
            } elseif ($objNode instanceof Node\Column) {
                /** @var Node\Column $objNode */
                $strOrderByCommand = $objNode->getColumnAlias($objBuilder);
            } elseif ($objNode instanceof iCondition) {
                /** @var iCondition $objNode */
                $strOrderByCommand = $objNode->getWhereClause($objBuilder);
            } else {
                $strOrderByCommand = '';
            }

            // Check to see if they want a ASC/DESC declarator
            if ((($intIndex + 1) < $intLength) &&
                !($this->objNodeArray[$intIndex + 1] instanceof Node\NodeBase)
            ) {
                if ((!$this->objNodeArray[$intIndex + 1]) ||
                    (trim(strtolower($this->objNodeArray[$intIndex + 1])) == 'desc')
                ) {
                    $strOrderByCommand .= ' DESC';
                } else {
                    $strOrderByCommand .= ' ASC';
                }
                $intIndex++;
            }

            $objBuilder->addOrderByItem($strOrderByCommand);
        }
    }
516261
public function count(array $locales = null,  array $filters = null)
    {
        $builder = $this->createQueryBuilder();

        $this->addTransUnitFilters($builder, $filters);
        $this->addTranslationFilter($builder, $locales, $filters);

        $count = $builder->count()
            ->getQuery()
            ->execute();

        return $count;
    }
120943
public function buildDataRequestQuery(DataRequest $dataRequest, QueryBuilder $queryBuilder, $entity, $tableCode)
    {
        $queryBuilder->select($tableCode)
                     ->from($entity, $tableCode);
        
        $hasWhere = false;
        $i = 1;
        foreach ($dataRequest->getFilters() as $filter) {
            $whereQuery = $tableCode . '.' . $filter->getFieldName() . ' ' . $filter->getMode() . ' :p' . $i;
            if ($hasWhere) {
                $queryBuilder->andWhere($whereQuery);
            } else {
                $queryBuilder->where($whereQuery);
                $hasWhere = true;
            }
            
            $queryBuilder->setParameter('p' . $i, $this->prepareValue($filter->getNeededValue(), $filter->getMode()));
            $i++;
        }
        
        // Sorting
        if ($dataRequest->hasSorting()) {
            $mode = 'ASC';
            if (in_array($dataRequest->getSortByDirection(), array('ASC', 'DESC'))) {
                $mode = $dataRequest->getSortByDirection();
            }
            
            $queryBuilder->orderBy($tableCode . '.' . $dataRequest->getSortBy(), $mode);
        }
        
        // Offset
        if ($dataRequest->hasRange()) {
            $queryBuilder->setFirstResult($dataRequest->getOffset());
            $queryBuilder->setMaxResults($dataRequest->getNumberOfEntries());
        }
    }
1100080
public function GetCustomCountQuery($objectclass, $criteria)
	{
		$this->IncludeModel($objectclass);
		$sql = call_user_func( array($objectclass,"GetCustomCountQuery"),$criteria );
		return $sql;
	}
777647
public function sqlLoadCount()
    {
        if (!$this->hasTable()) {
            throw new UnexpectedValueException(
                'Can not get SQL count. No table defined.'
            );
        }

        $tables  = $this->sqlFrom();
        $filters = $this->sqlFilters();

        $query = 'SELECT COUNT(*) FROM '.$tables.$filters;
        return $query;
    }
100634
protected function getDataTablesRepository(DataTablesProviderInterface $dtProvider) {

        $this->getLogger()->debug(sprintf("DataTables controller search for a repository with name \"%s\"", $dtProvider->getName()));

        $em = $this->getDoctrine()->getManager();

        $repository = $em->getRepository($dtProvider->getEntity());
        if (false === ($repository instanceOf DataTablesRepositoryInterface)) {
            throw new BadDataTablesRepositoryException($repository);
        }

        return $repository;
    }
1333528
protected function buildDataTablesCountExported(DataTablesProviderInterface $dtProvider) {

        $prefix = $dtProvider->getPrefix();

        $qb = $this->createQueryBuilder($prefix)
            ->select("COUNT(" . $prefix . ")");

        return $qb;
    }