Skip to content

Commit

Permalink
[DDC-2381] Wrong pagination query. Problems at large data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergic committed Apr 7, 2013
1 parent b2e29ea commit 2733c81
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public function walkSelectStatement(SelectStatement $AST)
));
}

// Build query with limit and offset before distincted query
$innerSql = $this->platform->modifyLimitQuery(
$innerSql, $this->maxResults, $this->firstResult
);

// Build the counter query.
$sql = sprintf('SELECT DISTINCT %s FROM (%s) dctrn_result',
implode(', ', $sqlIdentifier), $innerSql);
Expand All @@ -147,9 +152,9 @@ public function walkSelectStatement(SelectStatement $AST)
}

// Apply the limit and offset.
$sql = $this->platform->modifyLimitQuery(
$sql, $this->maxResults, $this->firstResult
);
//$sql = $this->platform->modifyLimitQuery(
// $sql, $this->maxResults, $this->firstResult
//);

// Add the columns to the ResultSetMapping. It's not really nice but
// it works. Preferably I'd clear the RSM or simply create a new one
Expand Down

3 comments on commit 2733c81

@TomasVotruba
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you.
Is there any easy way how to implement this in Doctrine without modifying it's code?

@Sergic
Copy link
Owner Author

@Sergic Sergic commented on 2733c81 Jun 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is way.
See how use Sonata Proxy Query.
and Sonata Pager

@TomasVotruba
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Could you give me simple use case outside the Sonata?

Please sign in to comment.