Skip to main content
Participant
December 12, 2012
Question

Struggling with array notation when converting to cfqueryparam

  • December 12, 2012
  • 1 reply
  • 594 views

I'm checking through some old code, tidying it up a little and making sure everything is using cfqueryparam - I've got the following bit of code and not sure what to do with it - I know cf_sql_array is available but I can't find any examples of information on it (or if that's exactly what I should be looking at):


<cffunction name="myfunction" access="public" returntype="void" output="false">

           <cfloop index="i" list="#visualList#">

               <cfif form["visual" & i] neq "NA">

              <cfquery name="assetVisualCheck" datasource="#APPLICATION.Config.dbdsnd#" username="#APPLICATION.Config.dbuname#" password="#APPLICATION.Config.dbpass#">

                    INSERT INTO assetVisual

                    (visualAssetID, visualBy, visualDate, visualResult)

                    Values ('#i#', '#cgi.REMOTE_USER#', now(), '#form["visual" & i]#')

                </cfquery>

                </cfif>

       </cfloop>

</cffunction>

list="#visualList#" should be a straightforward swap, #i# and #cgi.remote_user# don't need binding

'#form["visual" & i]#' is the bit I want to make sure is right. #form.visual1# is a "P", "F" or "X"

Am I overthinking this and it should just be

<cfqueryparam cfsqltype="cf_sql_char" maxlength="1" value="#ARGUMENTS["visual" & i]#"
This topic has been closed for replies.

1 reply

Inspiring
December 12, 2012

You are attempting to use the arguments scope without passing any arguments to the function.

Mi-ulAuthor
Participant
December 12, 2012

Arguments will be passed from elsewhere and will replace the values sent from the current FORM.

I want to make sure I'm on the right track before I start disassembling the code to move it to arguments