cosmicsafari
cosmicsafari

Reputation: 4049

ASP: What exactly is the purpose of this piece of code

I am currently attempting to transfer a project from ASP to PHP. I have no experience with ASP and I am finding it difficult to figure out exactly what the following lines are doing.

I probably should mention that the original solution wasn't built by myself and I am in the dark. If someone could provide a break down of what is actually happening here it would allow me to mimic the logic in PHP.

set rs_register = server.createobject("adodb.recordset")
        rs_register.cursorlocation = adUseClient
        rs_register.open str_products_sql, str_connection, adOpenStatic, adLockPessimistic '(CursorType,LockType)
        rs_register.addnew
                rs_register("str_session_id") = session.sessionid
                rs_register("str_payment_ip") = request.servervariables("remote_addr")
                rs_register.update  
                int_payment_id = rs_register("int_payment_id")
                rs_register("str_reference") = get_reference(int_payment_id,str_payment_type)
                rs_register.update
                str_reference = rs_register("str_reference")
                str_session_id = rs_register("str_session_id")

                if int_payment_id = "" then
                int_payment_id = rs_register("int_payment_id")
                end if
                rs_register.close : set rs_register = nothing

Upvotes: 0

Views: 26

Answers (1)

sgeddes
sgeddes

Reputation: 62861

To know for sure, you need to inspect the contents of str_products_sql -- this will tell you which table you are attempting to add a new record to:

rs_register.open str_products_sql

This command says you're adding a new record:

rs_register.addnew

Then you're setting a couple fields and saving to the database:

rs_register("str_session_id") = session.sessionid
rs_register("str_payment_ip") = request.servervariables("remote_addr")
rs_register.update  

After that, it then looks to read the int_payment_id field from the newly added record (perhaps an auto increment field or trigger) and then set the str_reference field based on another function (get_reference). After that, it just reads the results to local variables.

Upvotes: 1

Related Questions