遇到很大困难,望大家帮忙!!!(高分求解)
我是一个php新手,现在有一段asp代码,要转成php,可是我根本没接触过asp,php也不是很熟,可是公司要的很急,现把asp发上来,望高手给些指点:
'书的概要信息
Sub GetBookInfo(UserName, PassWord, UUID, bWithFile, codec)
On Error Resume Next
set cnnDBNet = Server.CreateObject("ADODB.Connection")
dim strConn
strConn = Application("Read_EnglishFreeNet2005_CStr")
cnnDBNet.ConnectionString = strConn
cnnDBNet.Open()
set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM ex3_bookshelf WHERE BOOKLANGUAGE='"&Trim(codec)&"' ORDER BY orderno"
rs.Open strSQL, cnnDBNet, 1
if (rs.eof) then
response.write "Result=0"
rs.close()
set rs=nothing
cnnDBNet.close
set cnnDBNet=nothing
Exit Sub
end if
nRecords = rs.RecordCount
nFields = rs.Fields.Count
Response.BinaryWrite inttobinary(nRecords) '输出二进制数,和客户端软件通信
Response.BinaryWrite inttobinary(nFields+3)
For i=0 to (nFields -1)
Dim FieldName
FieldName = rs.Fields(i).Name
FieldName = Trim(FieldName)
Dim FiledNameLen
FieldNameLen = Len(FieldName)
Response.BinaryWrite Inttobinary(FieldNameLen)
Response.Write FieldName
Next
Response.BinaryWrite Inttobinary(11)
Response.Write "lessontitle"
Response.BinaryWrite Inttobinary(9)
Response.Write "lessongif"
Response.BinaryWrite Inttobinary(13)
Response.Write "lessontasknum"
Response.Flush
For i=0 to (nRecords - 1)
For j=0 to (nFields - 1)
Dim strLen
Dim str
If IsNull(rs(j)) Then
Response.BinaryWrite inttobinary(0)
Response.Flush
Else
str = Trim(rs(j))
If rs.Fields(j).Name = "BOOKCOVER" AND bWithFile then
Dim url
Dim fso, fl, flsize
Dim objStream, data
url = DataPath&"\"&rs("BOOKPATH")&rs(j)
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set fl=fso.getfile(url)
flsize=fl.size
Set fl=Nothing
Set fso=Nothing
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Mode = 16
objStream.Open
objStream.Type = 1
objStream.LoadFromFile url
data = objStream.Read
strLen = stringLen(str)
Response.BinaryWrite inttobinary(strLen+flsize+8)
Response.BinaryWrite inttobinary(strLen)
Response.Write str
Response.BinaryWrite inttobinary(flsize)
Response.BinaryWrite data
Response.Flush
Response.Clear()
objStream.Close
Set objStream = Nothing
Else
strLen = stringLen(str)
Response.BinaryWrite inttobinary(strLen)
Response.Write str
Response.Flush
End If
End If
Next
set rs2 = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT D_TITLE,D_TASKNUM FROM "&Trim(rs("BOOKTABLENAME"))&" ORDER BY D_RECNO"
rs2.Open strSQL, cnnDBNet, 1
Dim totalstr,totalstr2,totalstr3
totalstr = ""
totalstr2 = ""
totalstr3 = ""
For k=0 to (rs2.RecordCount-1)
totalstr = totalstr & Trim(rs2.Fields("D_TITLE")) & chr(13)+chr(10)
totalstr2 = totalstr2 & Trim(rs2.Fields("D_TASKNUM"))&".gif" & chr(13)+chr(10)
totalstr3 = totalstr3 & Trim(rs2.Fields("D_TASKNUM")) & chr(13)+chr(10)
rs2.MoveNext
Next
Response.BinaryWrite inttobinary(stringLen(totalstr))
Response.Write totalstr
Response.BinaryWrite inttobinary(stringLen(totalstr2))
Response.Write totalstr2
Response.BinaryWrite inttobinary(stringLen(totalstr3))
Response.Write totalstr3
Response.Flush
rs2.close()
set rs2 = nothing
rs.MoveNext
Next
Response.Write "Result=1"
rs.close()
set rs=nothing
cnnDBNet.close
set cnnDBNet=nothing
End Sub
主要是asp取记录那段,如何转化为php的程序!!!!多谢大家了