改进对Page的解析位置

This commit is contained in:
thinkphp
2016-04-26 08:25:31 +08:00
parent 94c1ffb986
commit 67c47dd526
2 changed files with 9 additions and 8 deletions

View File

@@ -1455,6 +1455,15 @@ class Query
}
}
if (isset($options['page'])) {
// 根据页数计算limit
list($page, $listRows) = $options['page'];
$page = $page > 0 ? $page : 1;
$listRows = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20);
$offset = $listRows * ($page - 1);
$options['limit'] = $offset . ',' . $listRows;
}
$this->options = [];
return $options;
}