`Model::paginate()` behavior when `$page` exceeds the last page
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 Model::paginate() 入口點開始,使用 24 列和第 10 頁,透過提供的 load_more() 範例重現此行為。檢查產生的查詢是否保留要求的偏移量;完成標準是:即使第 10 頁沒有記錄,也會產生 LIMIT 80, 8。
由索引模型根據 Issue 內容生成。
描述
PHP Version
8.3
CodeIgniter4 Version
4.1.5
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
MySQL 5.6
What happened?
When i paginate the model like this $UsersMode->orderBy('id_user', 'ASC')->paginate(8, 'group', $page_number);
returns "SELECT * FROM users ORDER BY id_user ASC LIMIT 8, 8" based on offset and per page number
But my total count rows in the table are 24, so when i reach the end 16, 8 it returns me the same query as the last existing page in my database even with $page_number = 100
Steps to Reproduce
public function load_more($page_number = 2)
{
$UsersModel = new UsersModel();
$this->ViewData['Page'] = $page_number;
$this->ViewData['Users'] = $UsersMode->orderBy('id_user', 'ASC')->paginate(8, 'group', $page_number);
echo $UsersModel->db->getLastQuery();
}
returns "SELECT * FROM users ORDER BY id_user ASC LIMIT 8, 8"
But my total count rows in the table are 24, so when i reach the end 16, 8 $page_number = 10 and go to a page number more than 3 it returns the same query "SELECT * FROM users ORDER BY id_user ASC LIMIT 16, 8"
Expected Output
Going to a page number more than the total count rows of my table it should return the propper offset even if i have the total rows less than the per page number or less than the total count
$page_number = 10 it should returns the query "SELECT * FROM users ORDER BY id_user ASC LIMIT 80, 8" even if i don't have enough records in my database table
Anything else?
No response
- 主要語言
- PHP
- 星號
- 6k
- 分支
- 2k
- 平均合併
- 1 天 22 小時
- 30 天內合併 PR
- 59
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
codeigniter4/CodeIgniter4 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
codeigniter4/CodeIgniter4#10616 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 35/100
codeigniter4/CodeIgniter4#10618 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 62/100
codeigniter4/CodeIgniter4#10617 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 25/100
codeigniter4/CodeIgniter4#10615 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 48/100
codeigniter4/CodeIgniter4#10589 · 3 則留言 ·
維護者通常 1 天內回覆
查看 codeigniter4/CodeIgniter4 的全部 Issue
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 84/100
WordPress/hosting-handbook#506 ·
維護者通常 2 天內回覆
-
Installing a plugin with composer_packages installs dev dependencies and breaks the autoloader (Error 500)可能已有人在做 @Boy132 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
nginx: static-file locations drop the security headers, and the dotfile deny is matched after them未關閉bug Low Security
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 1/5 1 小時以內 新手友好度 78/100
backdrop-contrib/commerce#60 ·