时间:2021-05-28
复制代码 代码如下:
Function GetTable(Table,Where,Order,OrderSort,curpage, pagesize,MiniJson)
'Author : nigou
'使用方法 : Response.Write GetTable(Table表名,Where条件,Order主键(必须),OrderSort(asc,desc),curpage当前页, pagesize每页条数,MiniJson是否输出为miniUI格式)
'
dim i, j ,rs
if OrderSort="" Then OrderSort="asc"
if Where="" Then Where="asc"
Set Rs=Server.CreateObject("adodb.recordset")
if curpage>1 then
TmpSql="select a.* from ( select top " & (curpage) * pagesize & " * from " & Table & " where " & where & " order by " & Order & " " & OrderSort & ") a left join ( select top " & (curpage-1) * pagesize & " * from " & Table & " where " & where & " order by " & Order & " " & OrderSort & ") b on a." & Order & "=b." & Order & " where iif(b." & Order & ",'0','1')='1'"
else
TmpSql="select a.* from ( select top " & (curpage) * pagesize & " * from " & Table & " where " & where & " order by " & Order & " " & OrderSort & ") a "
end if
if pagesize=0 Then TmpSql = "select * from " & Table
Rs.open TmpSql,conn,1,1
RealSize=Rs.recordcount
for i=0 to Rs.recordcount-1
TmpJson= TmpJson & "{"
for j=0 to Rs.fields.count-1
TmpJson= TmpJson & """" &(Rs.fields(j).name) & """ : "
TmpJson= TmpJson & """" & Rs(j) & """"
if j<Rs.fields.count-1 then TmpJson= TmpJson & " , "
next
TmpJson= TmpJson & " }"
if i<Rs.recordcount-1 then TmpJson= TmpJson & ","
TmpJson= TmpJson & vbcrlf
rs.movenext
next
Rs.close
if MiniJson=1 Then
CountSql="select count("& order &") from " & Table & " where " & where
Rs.open CountSql,Conn,1,1
Counts=Rs(0)
Rs.Close
GetTable=ToMiniUi(TmpJson,Counts)
Else
GetTable=toJson(TmpJson)
end if
Set Rs=nothing
End Function
function toJson(JsonStr)
toJson="[" & vbcrlf & JsonStr & vbcrlf & "]"
end function
Function ToMiniUi(JsonStr,total)
ToMiniUI="{"
ToMiniUI=ToMiniUI & """total"":"" " & total & """," & vbcrlf
ToMiniUI=ToMiniUI & """data"": [" & JsonStr
ToMiniUI=ToMiniUI & "]}"
End Function
PS:最后的参数是针对miniUI开发的,可以无视
以上就是本文的全部内容了,希望大家能够喜欢。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
首先来看,ASP读取ACCESS数据库。复制代码代码如下:
本文实例讲述了vue.js实现数据库的JSON数据输出渲染到html页面功能。分享给大家供大家参考,具体如下:1、首先通过json.php把数据库给输出为jso
Asp实现数据库ID复制代码:
本文实例讲述了thinkphp5框架实现数据库读取的数据转换成json格式。分享给大家供大家参考,具体如下:首先从数据库读数据,然后调用list_to_tree
本文实例讲述了thinkPHP5实现的查询数据库并返回json数据。分享给大家供大家参考,具体如下:TP5实现查询数据库返回json数据(返回json数据函数实