mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
改进对Page的解析位置
This commit is contained in:
@@ -494,14 +494,6 @@ abstract class Builder
|
||||
*/
|
||||
public function select($options = [])
|
||||
{
|
||||
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;
|
||||
}
|
||||
$sql = str_replace(
|
||||
['%TABLE%', '%DISTINCT%', '%FIELD%', '%JOIN%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%', '%UNION%', '%LOCK%', '%COMMENT%', '%FORCE%'],
|
||||
[
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user