My previous problem was a simple enough to solve by setting the 'with' property and by applying a default sort column.
But now I am experiencing the OP's problem even after applying le_top's CPagination change.
My table has 11666 records and pages 18 and 19 have identical results.
I took a look at the queries that were generated and they indeed do give the same results when executed in SQL Server Management Studio.
The inner most subquery is fine and delivers different results for both "pages". However, when the outer subquery is applied the same results are collected. MSSQL now supports OFFSET and FETCH so I might look into translating from the MySQL queries.
Edit: I just fixed my problem. In CMssqlCommandBuilder there is a method called rewriteLimitOffsetSql (this method attempts to rewrite the limit portion of queries using the "subquery method"). As I mentioned before since MSSQL now supports OFFSET and FETCH I just commented out the code and replaced it with a single line that translates to the appropriate syntax usage.
protected function rewriteLimitOffsetSql($sql, $limit, $offset)
{
return $sql." OFFSET ".$offset." ROWS FETCH NEXT ".$limit." ROWS ONLY";
/*
$fetch = $limit+$offset;
$sql = preg_replace('/^([\s(])*SELECT( DISTINCT)?(?!\s*TOP\s*\()/i',"\\1SELECT\\2 TOP $fetch", $sql);
$ordering = $this->findOrdering($sql);
$orginalOrdering = $this->joinOrdering($ordering, '[__outer__]');
$reverseOrdering = $this->joinOrdering($this->reverseDirection($ordering), '[__inner__]');
$sql = "SELECT * FROM (SELECT TOP {$limit} * FROM ($sql) as [__inner__] {$reverseOrdering}) as [__outer__] {$orginalOrdering}";
return $sql;
*/
}
This post has been edited by genosha: 23 February 2013 - 06:13 AM