Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

mssql 分页错误 #166

Open
qiangxue opened this Issue · 0 comments

1 participant

@qiangxue
Owner

共4条,每页3条,第2页应该只显示第4条才对,但是会显示3条。

经过查找发现源码是错误的,谁修正,mssql这样写最后一页有问题的 永远会取limit条
framework\db\schema\mssql\CMssqlCommandBuilder.php
protected function rewriteLimitOffsetSql($sql, $limit, $offset)
{
$fetch = $limit+$offset;
$sql = preg_replace('/^([\s(])SELECT( DISTINCT)?(?!\sTOP\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;
}

Migrated from http://code.google.com/p/yii/issues/detail?id=2864


earlier comments

qiang.xue said, at 2012-01-01T03:36:54.000Z:

set for 1.1.10 milestone

@qiangxue qiangxue was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.