Accessing data in a coldfusion query object

The syntax is:

queryvariable.columnname[rownumber]

It would seem that the query datatype is an array of structs. Indeed as I read some posts online, I discovered a query is like an array of structs. But the query object is a special data type in coldfusion, like an array or a struct. See the Adobe article linked below.

I don’t know why this was so hard to find in the livedocs, or why the ColdFusion documentation for cfquery didn’t have any useful links, but Joel was able to point out to me right off that you can access the data in the rows/fields of a cfquery easily.

I’ll quote Adobe’s livedocs here, in a buried artilce. I ended up finding this useful page with a google search.

“A query object, sometimes referred to as a query, query result, or record set, is a complex ColdFusion data type that represents data in a set of named columns, similar to the columns of a database table.”

“You reference query columns by specifying the query name, a period, and the column name”

“You can access query columns as if they are one-dimensional arrays.”

Ex:<cfset myVar = myQuery.Employee[2]>”

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Variables_17.html

Leave a Reply

Your email address will not be published. Required fields are marked *