How To Create a Coldfusion Struct Using a Query
Posted on 2012-03-28
I would like to create a structure with the data from a query in coldfusion 9.
The data ultimatley needs to be put into a chart for display.
I can not get all of the needed data in my initial query because some of the fields are encrypted and so I have to decrypt them on the page to retrieve the actual values.
I want to create a structure to hold the initial data and the decrypted data and use that as a basis to fill a cfchart.
I'm having a little trouble with the syntax. I've previously have done this type of thing with an array but I'd like to use a structure.
Can you offer some advice on how to correctly create a struct from a cfquery?
This is what I have:
<cfquery name="somequery" >
select field1, encryptedField2 from mytable
<cfset MyStruct = StructNew()>
<cfset MyStruct.thing1 = "x">
<cfset Mystruct.thing2 = "y">
<cfset decryptedVal = #functionToDecrypt#>
StructInsert(MyStruct, "field1", field1)>
StructInsert(Mystruct, "decryptedField2, DecryptedThing)>