Programming Language PHP

Namespace Oro\Component\DoctrineUtils\ORM

Class QueryBuilderUtil

Method/Function removeUnusedParameters

Total Examples 2

2 code examples of PHP Oro\Component\DoctrineUtils\ORM\QueryBuilderUtil::removeUnusedParameters extracted from open source projects

Was this example useful?
0
                                                    /**
     * Get total row data from database
     *
     * @param ResultsObject $pageData Grid page data
     * @param array $columnsConfig Total row columns config
     * @param bool $perPage Get data only for page data or for all data
     * @param bool $skipAclWalkerCheck Check Acl with acl helper or not
     */
    protected function getData(ResultsObject $pageData, array $columnsConfig, bool $perPage = false, bool $skipAclWalkerCheck = false): array
    {
        // this method requires refactoring, see BAP-17427 for details
        $totalQueries = [];
        foreach ($columnsConfig as $field => $totalData) {
            if (isset($totalData[Configuration::TOTALS_SQL_EXPRESSION_KEY])
                && $totalData[Configuration::TOTALS_SQL_EXPRESSION_KEY]
            ) {
                $totalQueries[] = $totalData[Configuration::TOTALS_SQL_EXPRESSION_KEY] . ' AS ' . $field;
            }
        }

        $queryBuilder = clone $this->masterQB;
        $queryBuilder
            ->select($totalQueries)
            ->resetDQLParts(['groupBy', 'having']);

        $this->addPageLimits($queryBuilder, $pageData, $perPage);

        QueryBuilderUtil::removeUnusedParameters($queryBuilder);

        $query = $queryBuilder->getQuery();

        if (!$skipAclWalkerCheck) {
            $query = $this->aclHelper->apply($query);
        }

        $resultData = $query
            ->setFirstResult(null)
            ->setMaxResults(1)
            ->getScalarResult();

        return array_shift($resultData);
    }
                                            
Was this example useful?
0
                                                    /**
     * Removes unused parameters from query builder
     */
    public function fixUnusedParameters(QueryBuilder $qb)
    {
        QueryBuilderUtil::removeUnusedParameters($qb);
    }