-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagination.py
36 lines (33 loc) · 1.06 KB
/
pagination.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Name: Pagination
# Purpose:
#
# Author: viperasi
#
# Created: 13/07/2012
# Copyright: (c) xu81.com 2012
# Licence: <your licence>
#-------------------------------------------------------------------------------
import web
from dbengine import DBEngine
class Pagination:
def __init__(self, table, var, what, where, order, limit, currPage):
self.table = table
self.var = var
self.what = what
self.where = where
self.limit = limit
self.order = order
self.currPage = currPage
self.allPage = 0
def getInstance(self):
db = DBEngine().getInstance()
results = db.select(self.table, vars=self.var, what=self.what,where=self.where,order=self.order)
count = results[0].count
mod = int(count) % self.limit
if mod == 0:
self.allPage = int(count) / self.limit
else:
self.allPage = int(count) / self.limit + 1
return self