Database Sub-page algorithm Leadbbs

xiaoxiao2021-03-05  24

Class Pg_Jet_Ex Private sCodeVer, sCodeName, sCoder, sDis Private Toward, Backward, TowardOrder, BackwardOrder Private IdxSql, QuerySql Public Conn Public PageCount, ItemCount, PageItemCount Public PageLast, PageStart Public ViewPage, ToPage, Division, StepPage, StartID Public OrderKey, OrderMode Public IdxTable , Idxkey, queryys, querywhere private sub coplass_initialize () scodever = "1.1.050115" scodeName = "JetPage Leader!" Scoder = "ASHI" SDIS = "data paging class.

"ViewPage = 1 'Browse page TOPAGE = 1' Go to Page Division = 20 'Each page STEPPAGE = 5' Allow Maximum Jump Table STARTID = 0 'Index Query Start Record Number, optimized Query PageCount = 0' page Total number Itemcount = 0 'Recording Total ORDERKEY = "ID"' Sort field, use index fields in the database, existing data in the index table and data table, have a unique value in the table ORDERMODE = "ASC" 'Sort by IdxKey = "ID" index field name, existing field idXTable = "" "" "'index table idxwhere =" "" query field name queryTable = "" "query table queryTable =" "" Querywhere = "" "'Query WHERE End Sub Private Sub Orderchoose () Select Case Lcase (OrderMode) Case" Desc "ORDERMODE =" DESC "Toward =" <"TowardOrder =" DESC "Backward ="> "Backwardorder =", "case else =", "to else ordermode =", "touth ="> "toardorder =" ASC "backward =" <"backwardorder =" desc "End Select End Sub Private Sub CountPage () DIM RS, SQL, St Idxwhere <> ""

THEN ST = "Where" & idxwhere sql = "select count (*) from" & idxTable & St 'debug.addsql (sql)' sys.dbplus () set = conn.execute (sql) if NOT = CONN.EOF THEN Itemcount = ccur (RS (0)) end if = Nothing end Sub Private Sub Listpage () DIM IMOVEPG, IAMOVEPG DIM ITOP, IDIS, I, ITC DIM IMODE DIM RS, AT, AW, SW DIM st PageCount = ItemCount / Division If ItemCount Mod Division> 0 Then PageCount = PageCount 1 If ToPage = <1 Then iMode = 1 ElseIf ToPage> = PageCount Then if startId <= 0 Then iMode = -1 Else iMode = 0 iMovePg = ToPage - ViewPage IAmovepg = ABS (Imovepg) ITOP = IAMOVEPG * DI vision iDis = iTop - Division If iaMovePg> StepPage Or iaMovePg = 0 Then iMode = -1 If StartID = <0 Then iMode = -1 End If Else iMode = 0 iMovePg = ToPage - ViewPage iaMovePg = Abs (iMovePg) iTop = iaMovePg * Division Idis = ITOP - Division if iamovepg> Steppage or amovepg = 0 Then Imode = 1 if startID = <0 Then Imode =

1 end if if idxwhere <> "" "" "" "" = 1 ket = Division IDis = 0 imovepg = 1 if PageCount = 1 Then ITOP = ITEMCOUNT ITXSQL = "SELECT TOP" & ITOP & "& Idxkey &" from "& idXTable & St &" Order By "& OrderKey &" & TowardOrder Case -1 Topage = PageCount ITOP = ITEMCOUNT - (PageCount - 1) * Division IDis = 0 Imovepg = -1 idxsql = "SELECT TOP" & ITOP & "& iDXKey &" From "& OrderKey &" & BakewardOrder Case 0 if idxwhere <> "" "" <0 THEN IDXSQL = "SELECT TOP" & ITOP & "& Idxkey &" From "& iDXTable &" WHERE "& ST & ORDERKEY & BACKWARD & StartID &" Order by "& OrderKey &" & BackwardOrder else idxsql = "select top" & ITOP & "& Idxkey &" from "& idxTable &"

"WHERE" & St & ORDERKEY & TOWARD & Startid & "Order by" & OrderKey & "& TowardOrder End If End Select Set Rs = Conn.Execute (IDXSQL) 'Debug.addsql idxsql' sys.dbplus if xi r e d t Rs.close () SET RS = NOTHING SET CONN = NOTING SYS.SHOWERR ScodeName, Scodever, "Did not find the requested index (" & idxsql & ").

"Else if idis> 0 Then Rs.move (idis) if q = 1 = Nothing top = 1 listpage () EXIT SUB END IF AW = rs.getRows (-1) rs.close ( ) SET RS = Nothing ITC = Ubound (AW, 2) Redim At (ITC) for i = 0 to ITC AT (i) = AW (0, i) Next AW = Empty IF IMOVEPG <0 THEN PageStart = At ​​(ITC) Pagelast = at (0) Else Pagestart = At ​​(0) Pagelast = At ​​(ITC) end if IF isnumeric (at (0)) THEN SW = JOIN (AT, ",") Else SW = "'" & join , "','") & "'" End if if Querywhere <> "" "and" end if Querywhere & "SELECT" & QueryKeys & "From" & queryTable & "Where" & querywhere & idks "in (" & SW & ") Order BY "& OrderKey &" & OrderMode 'debug.addsql (querysql)' sys.dbplus () end if PageItemcount = ITC

1 ViewPage = ToPage End Sub Public Property Get Rec () If ItemCount = 0 Then CountPage () End If OrderChoose () ListPage () Rec = Conn.Execute (QuerySql) .Getrows (-1) End PropertyEnd Class call Example: Dim objSet Obj = new PG_JET_EXWITH OBJ.DIVISION = 20 .idxkey = "id" .idxtable = "marklist" .queryKeys = "test number, name, language total score" .queryTable = "marklist" .steppage = 5 .ViewPage = sys.requestnum ("p") .topage = sys.requestnum ("t") .StartId = sys.requestnum ("s") .oterkey = "id" .otermode = "asc" .IdenMcount = 375 set .conn = MCON RS = .Rec set .conn = Nothing set mcon = Nothingend withwith xs.load "plug_mark2" .Openntag "marks" .tag "item" for i = 0 to obj.pageItemcount - 1 .pvar (Array "," test number "," Name "," Language Total Size ")) = Array (i 1, RS (0, I), RS (1, I), RS (2, I)) Next .endtag .pvar ) = obj.pagestart .pvar ("EN ") = obj.pagelast .pvar (" Viewpage ") = obj.viewpage .pvar (" pagecount ") = obj.pagecount .pvar (" itemcount ") = obj.Itemcount .pvar (" division ") = Obj. DiVision if b1 .pvar ("Ableorder") = "" "" "" "" "" "" "" "" "" "" "" "" "" ""

转载请注明原文地址:https://www.9cbs.com/read-32271.html

New Post(0)