易心asp分頁(yè)類 v1.0
易心asp分頁(yè)類v1.0
<%
class ex_splitpagecls
'==========================================================================
'易心asp分頁(yè)類v1.0
'作者:易心 qq:343931221
'個(gè)人網(wǎng)站 www.ex123.net www.bo56.com
'演示地址:www.ex123.net/show/page
'轉(zhuǎn)載請(qǐng)保留此信息
'==========================================================================
dim ex_rs
dim ex_columns'要提取的字段
dim ex_datafrom'數(shù)據(jù)表名
dim ex_strwhere'記錄篩選條件
dim ex_order'sql排序
dim ex_idcount'記錄總數(shù)
dim ex_pagesize'每頁(yè)條數(shù)
dim ex_pagecount'總頁(yè)數(shù)
dim ex_ids'獲得本頁(yè)要用到的id
dim ex_sql'構(gòu)造的sql語(yǔ)句
dim ex_page'當(dāng)前顯示頁(yè)碼
dim ex_conn'數(shù)據(jù)庫(kù)聯(lián)接對(duì)象
dim ex_index'數(shù)據(jù)庫(kù)記錄當(dāng)前位置
dim ex_id'主鍵字段
private sub class_initialize
set ex_rs=server.createobject("adodb.recordset")
ex_id="id"
ex_pagesize=20
end sub
private sub class_terminate
ex_rs.close
set ex_rs=nothing
end sub
'屬性賦值:
public property let letconn(str)
ex_conn=str
end property
'屬性賦值:sql語(yǔ)句 要查詢的字段 帶select
public property let letcolumns(str)
ex_columns=str
end property
'屬性賦值:sql語(yǔ)句篩選條件部分 帶where
public property let letwhere(str)
ex_strwhere=str
end property
'屬性賦值:sql語(yǔ)句數(shù)據(jù)表 帶from
public property let letdatafrom(str)
ex_datafrom=str
end property
'屬性賦值:sql語(yǔ)句排序部分 帶order by
public property let letorder(str)
ex_order=str
end property
'屬性賦值:每頁(yè)記錄數(shù)
public property let letpagesize(str)
ex_pagesize=str
end property
'屬性賦值:當(dāng)前頁(yè)數(shù)
public property let letpage(str)
ex_page=str
end property
'屬性賦值:主表主鍵字段
public property let letid(str)
ex_id=str
end property
'屬性:獲得記錄總數(shù)
public property get getrscount
getrscount=ex_idcount
end property
'屬性:獲得頁(yè)總數(shù)
public property get getpagecount
if(ex_idcount>0) then'如果記錄總數(shù)=0,則不處理
if(ex_idcount mod ex_pagesize=0)then'如果記錄總數(shù)除以每頁(yè)條數(shù)有余數(shù),則=記錄總數(shù)/每頁(yè)條數(shù)+1
ex_pagecount=int(ex_idcount/ex_pagesize)'獲取總頁(yè)數(shù)
else
ex_pagecount=int(ex_idcount/ex_pagesize)+1'獲取總頁(yè)數(shù)
end if
getpagecount=ex_pagecount
else
getpagecount=0
end if
end property
'屬性:獲得當(dāng)前頁(yè)數(shù)
public property get getpage
getpage=ex_page
end property
'獲得本頁(yè)要用到的id
private sub ids
dim i
ex_sql="select "&ex_id&" "& ex_datafrom &" " &" "&ex_strwhere&" "&ex_order
ex_rs.open ex_sql,ex_conn,1,1
if not ex_rs.eof and not ex_rs.bof then
ex_rs.pagesize =ex_pagesize '每頁(yè)顯示記錄數(shù)
ex_rs.absolutepage=cint(ex_page)
ex_idcount=ex_rs.recordcount
if ex_page < 1 then ex_page = 1
if ex_page > ex_pagecount then ex_page = ex_pagecount
if ex_pagecount > 0 then ex_rs.absolutepage =ex_page
for i=1 to ex_rs.pagesize
if ex_rs.eof then exit for
if(i=1)then
ex_ids=ex_rs("id")
else
ex_ids=ex_ids &","&ex_rs("id")
end if
ex_rs.movenext
next
end if
ex_rs.close
end sub
'返回本頁(yè)要用到的記錄集
public function execute
ids
ex_sql=ex_columns&" "&ex_datafrom&" "&ex_strwhere&" and id in("&ex_ids&") "&ex_order
ex_rs.open ex_sql,ex_conn,1,1
set execute=ex_rs
end function
end class
%>
代碼如下:
<%
class ex_splitpagecls
'==========================================================================
'易心asp分頁(yè)類v1.0
'作者:易心 qq:343931221
'個(gè)人網(wǎng)站 www.ex123.net www.bo56.com
'演示地址:www.ex123.net/show/page
'轉(zhuǎn)載請(qǐng)保留此信息
'==========================================================================
dim ex_rs
dim ex_columns'要提取的字段
dim ex_datafrom'數(shù)據(jù)表名
dim ex_strwhere'記錄篩選條件
dim ex_order'sql排序
dim ex_idcount'記錄總數(shù)
dim ex_pagesize'每頁(yè)條數(shù)
dim ex_pagecount'總頁(yè)數(shù)
dim ex_ids'獲得本頁(yè)要用到的id
dim ex_sql'構(gòu)造的sql語(yǔ)句
dim ex_page'當(dāng)前顯示頁(yè)碼
dim ex_conn'數(shù)據(jù)庫(kù)聯(lián)接對(duì)象
dim ex_index'數(shù)據(jù)庫(kù)記錄當(dāng)前位置
dim ex_id'主鍵字段
private sub class_initialize
set ex_rs=server.createobject("adodb.recordset")
ex_id="id"
ex_pagesize=20
end sub
private sub class_terminate
ex_rs.close
set ex_rs=nothing
end sub
'屬性賦值:
public property let letconn(str)
ex_conn=str
end property
'屬性賦值:sql語(yǔ)句 要查詢的字段 帶select
public property let letcolumns(str)
ex_columns=str
end property
'屬性賦值:sql語(yǔ)句篩選條件部分 帶where
public property let letwhere(str)
ex_strwhere=str
end property
'屬性賦值:sql語(yǔ)句數(shù)據(jù)表 帶from
public property let letdatafrom(str)
ex_datafrom=str
end property
'屬性賦值:sql語(yǔ)句排序部分 帶order by
public property let letorder(str)
ex_order=str
end property
'屬性賦值:每頁(yè)記錄數(shù)
public property let letpagesize(str)
ex_pagesize=str
end property
'屬性賦值:當(dāng)前頁(yè)數(shù)
public property let letpage(str)
ex_page=str
end property
'屬性賦值:主表主鍵字段
public property let letid(str)
ex_id=str
end property
'屬性:獲得記錄總數(shù)
public property get getrscount
getrscount=ex_idcount
end property
'屬性:獲得頁(yè)總數(shù)
public property get getpagecount
if(ex_idcount>0) then'如果記錄總數(shù)=0,則不處理
if(ex_idcount mod ex_pagesize=0)then'如果記錄總數(shù)除以每頁(yè)條數(shù)有余數(shù),則=記錄總數(shù)/每頁(yè)條數(shù)+1
ex_pagecount=int(ex_idcount/ex_pagesize)'獲取總頁(yè)數(shù)
else
ex_pagecount=int(ex_idcount/ex_pagesize)+1'獲取總頁(yè)數(shù)
end if
getpagecount=ex_pagecount
else
getpagecount=0
end if
end property
'屬性:獲得當(dāng)前頁(yè)數(shù)
public property get getpage
getpage=ex_page
end property
'獲得本頁(yè)要用到的id
private sub ids
dim i
ex_sql="select "&ex_id&" "& ex_datafrom &" " &" "&ex_strwhere&" "&ex_order
ex_rs.open ex_sql,ex_conn,1,1
if not ex_rs.eof and not ex_rs.bof then
ex_rs.pagesize =ex_pagesize '每頁(yè)顯示記錄數(shù)
ex_rs.absolutepage=cint(ex_page)
ex_idcount=ex_rs.recordcount
if ex_page < 1 then ex_page = 1
if ex_page > ex_pagecount then ex_page = ex_pagecount
if ex_pagecount > 0 then ex_rs.absolutepage =ex_page
for i=1 to ex_rs.pagesize
if ex_rs.eof then exit for
if(i=1)then
ex_ids=ex_rs("id")
else
ex_ids=ex_ids &","&ex_rs("id")
end if
ex_rs.movenext
next
end if
ex_rs.close
end sub
'返回本頁(yè)要用到的記錄集
public function execute
ids
ex_sql=ex_columns&" "&ex_datafrom&" "&ex_strwhere&" and id in("&ex_ids&") "&ex_order
ex_rs.open ex_sql,ex_conn,1,1
set execute=ex_rs
end function
end class
%>
相關(guān)文章
- ASP怎么談到應(yīng)用到類的?
- 檢測(cè)函數(shù) asp class
- 遭遇ASP類的事件設(shè)計(jì)
- ASP高亮類
- Object對(duì)象的一些的隱藏函數(shù)介紹
- 淺談ASP中的類
- 在VBScript中使用類
- ASP 類專題
- 代碼與頁(yè)面的分離
- ASP代碼的對(duì)象化
- 一個(gè)asp快速字符串連接類
- 一個(gè)簡(jiǎn)單的asp數(shù)據(jù)庫(kù)操作類
- ASP類編寫詳細(xì)說明
- 實(shí)現(xiàn)支持邏輯搜索/單詞搜索/詞組搜索+支持OR/AND關(guān)鍵字的VBS CLASS!
- ASP類Class入門 推薦
- 創(chuàng)建一個(gè)ASP通用分頁(yè)類
- 如何編寫一個(gè)ASP類
- 一個(gè)ACCESS數(shù)據(jù)庫(kù)訪問的類第1/3頁(yè)
- 分頁(yè)類,異常類
- ASP 類 Class入門