Skip to content

Commit

Permalink
Merge pull request #8 from jonathanj33/dev-distinct-top
Browse files Browse the repository at this point in the history
[MSSQL] Get distinct before top for query
  • Loading branch information
GromNaN committed Feb 5, 2014
2 parents 9bef325 + d971a7b commit b7682da
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/Doctrine/Connection/Mssql.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ public function modifyLimitQuery($query, $limit = false, $offset = false, $isMan
}

if ($offset == 0) {
$query = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $limit . ' ', $query);

$query = preg_replace('/^SELECT( DISTINCT)?\s/i', 'SELECT\1 TOP ' . $limit . ' ', $query);
} else {
$over = stristr($query, 'ORDER BY');

Expand Down

0 comments on commit b7682da

Please sign in to comment.