• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Struggling with array notation when converting to cfqueryparam

Community Beginner ,
Dec 12, 2012 Dec 12, 2012

Copy link to clipboard

Copied

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]#"

Views

501

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 12, 2012 Dec 12, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 12, 2012 Dec 12, 2012

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation