lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
private function recreateInnerSql(
        OrderByClause $orderByClause,
        array $identifiers,
        string $innerSql
    ) : string {
        [$searchPatterns, $replacements] = $this->generateSqlAliasReplacements();

        $orderByItems = [];

        foreach ($orderByClause->orderByItems as $orderByItem) {
            // Walk order by item to get string representation of it and
            // replace path expressions in the order by clause with their column alias
            $orderByItemString = preg_replace(
                $searchPatterns,
                $replacements,
                $this->walkOrderByItem($orderByItem)
            );

            $orderByItems[] = $orderByItemString;
            $identifier     = substr($orderByItemString, 0, strrpos($orderByItemString, ' '));

            if (! in_array($identifier, $identifiers, true)) {
                $identifiers[] = $identifier;
            }
        }

        return $sql = sprintf(
            'SELECT DISTINCT %s FROM (%s) dctrn_result_inner ORDER BY %s',
            implode(', ', $identifiers),
            $innerSql,
            implode(', ', $orderByItems)
        );
    }
private function recreateInnerSql(
        OrderByClause $orderByClause,
        array $identifiers,
        string $innerSql
    ) : string {
        [$searchPatterns, $replacements] = $this->generateSqlAliasReplacements();

        $orderByItems = [];

        foreach ($orderByClause->orderByItems as $orderByItem) {
            // Walk order by item to get string representation of it and
            // replace path expressions in the order by clause with their column alias
            $orderByItemString = preg_replace(
                $searchPatterns,
                $replacements,
                $this->walkOrderByItem($orderByItem)
            );

            $orderByItems[] = $orderByItemString;
            $identifier     = substr($orderByItemString, 0, strrpos($orderByItemString, ' '));

            if (! in_array($identifier, $identifiers, true)) {
                $identifiers[] = $identifier;
            }
        }

        return $sql = sprintf(
            'SELECT DISTINCT %s FROM (%s) dctrn_result_inner ORDER BY %s',
            implode(', ', $identifiers),
            $innerSql,
            implode(', ', $orderByItems)
        );
    }
private function recreateInnerSql ( OrderByClause $ orderByClause , array $ identifiers , string $ innerSql ) : string { [ $ searchPatterns , $ replacements ] = $ this -> generateSqlAliasReplacements ( ) ; $ orderByItems = [ ] ; foreach ( $ orderByClause -> orderByItems as $ orderByItem ) { // Walk order by item to get string representation of it and // replace path expressions in the order by clause with their column alias $ orderByItemString = preg_replace ( $ searchPatterns , $ replacements , $ this -> walkOrderByItem ( $ orderByItem ) ) ; $ orderByItems [ ] = $ orderByItemString ; $ identifier = substr ( $ orderByItemString , 0 , strrpos ( $ orderByItemString , ' ' ) ) ; if ( ! in_array ( $ identifier , $ identifiers , true ) ) { $ identifiers [ ] = $ identifier ; } } return $ sql = sprintf ( 'SELECT DISTINCT %s FROM (%s) dctrn_result_inner ORDER BY %s' , implode ( ', ' , $ identifiers ) , $ innerSql , implode ( ', ' , $ orderByItems ) ) ; }
Generates a new SQL statement for the inner query to keep the correct sorting

@param mixed[][] $identifiers
Generates a new SQL statement for the inner query to keep the correct sorting