數據庫分頁(yè)功能
某次查詢(xún)實(shí)現了以下功能便可以將page_html和result返回模板作為分頁(yè)模板和分頁(yè)數據
where = '`webid`=12' # 查詢(xún)條件 page = 2 # 調用第幾頁(yè)數據 limit = 10 # 每頁(yè)顯示多少行數據 # 問(wèn)題答案列表 result = self.db.list( table="question_result", field='answer', where=where, page=page, limit=limit ) if page and page > self.db.total_page: page = self.db.total_page result = self.db.list( table="question_result", field='answer', where=where, page=page, limit=limit ) from kyger.common import page_tpl page_html = page_tpl(self.db.page, self.db.total_page, 10, self.kg['server'].get('WEB_URL')) # 獲取分頁(yè)模板 total_rows = self.db.total_rows # 總記錄數 total_page = self.db.total_page # 總頁(yè)數
適應版本
v1.0.1