Last active
August 29, 2015 14:19
-
-
Save aliaspooryorik/09e8585a0b54ec23ac2b to your computer and use it in GitHub Desktop.
Is it an array?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset q = queryNew("id")> | |
<cfloop from=1 to=5 index="index"> | |
<cfset queryAddRow(q)> | |
<cfset querySetCell(q, "id", index)> | |
</cfloop> | |
<cfdump var="#arrayLen(q["id"])#"><!--- this shows 5 ---> | |
<cfdump var="#arrayAvg(q["id"])#"><!--- this shows 3 ---> | |
<cfdump var="#arraySum(q["id"])#"><!--- this shows 15 ---> | |
<cfdump var="#q["id"][4]#"><!--- this shows 4 ---> | |
<cfoutput>#serializeJSON(q["id"])#</cfoutput> | |
<!--- so it's definately an array - or is it... ---> | |
<cfoutput>#serializeJSON(q.id)#</cfoutput> | |
<cfdump var="#q.id#"> <!--- this shows 1 ---> | |
<cfdump var="#q["id"]#"> <!--- this shows 1 ---> | |
<cfoutput>#q.id#</cfoutput> <!--- this shows 1 ---> | |
<!---<cfoutput>#q["id"]#</cfoutput> this throws error about complex type ---> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested on CF10. If
<cfoutput>#q.id#</cfoutput>
works (so is shorthand forq.id[1]
), why doesn't<cfoutput>#q["id"]#</cfoutput>
?