> -----Original Message-----
> From: Johnny Le [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 28, 2005 10:07 AM
> To: CF-Talk
> Subject: Re: Best practice question?
>
> I just tried ArraySum(queryname["fieldname"]) and it works, but when I
> tried to get the array queryname["fieldname"], all I got is the value of
> the first row. I use <cfdump var="#queryname["fieldname"]#>. I used
> <cfset something = queryname["fieldname"]/>. None of them comes out as an
> array.
It's definitely at least a little flakey (which is why I stressed testing
this stuff out first). It seems to only be an array on a direct access, not
an assignment. So the following all work fine:
+) IsArray(QueryName["Column"]) does indeed return "Yes".
+) <cfloop from="1" to="#ArrayLen(QueryName["Column"])#" index="Cnt"> works
just fine.
+) ArrayToList(QueryName["Column"]) gives you a list of all column values
(as would "ValueList()").
However you're right: when making an assignment (which, I _think_ CFDump
does internally) you get the value of the first row.
So <cfset foo = QueryName["Column"] /> has the same result as <cfset foo =
QueryName.Column />
However things get stranger still because this
<cfoutput>#QueryName["Column"]#</cfoutput>
actually results in a error ("Complex object types cannot be converted to
simple values.") were this
<cfoutput>#QueryName.Column#</cfoutput>
results in the output of the first cell of the column.
So while you can use the indexed notation reference as an array nearly every
place you can't copy it. At least not simply - however you CAN duplicate
it! The following will get you your array:
<cfset foo = Duplicate(QueryName["Column"]) />
"Foo" will now be an array of all values in the column.
I'm sure that's not exhaustive, but I hope it at least frames how this works
and further underlines the point to test it out before you rely on it.
Jim Davis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:200207
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54