loo
loo

Reputation: 707

Parsing CFDUMP struct and store values

How do I parse this structure? I need to turn this into single variables. E.g. from the attributes struct:

name

type

value

I'm not familiar with structures, and I need to enter this type of data into a database.

I've played around with cfloop, but nothing.

cfdump

Upvotes: 6

Views: 1540

Answers (3)

Adam Bellas
Adam Bellas

Reputation: 322

Along the same lines as what Ben said, I'm not sure why you'd want to pull this nice little struct apart. Use it in its current form by accessing the values inside it rather than disassembling it.

<cfloop collection="#foo.attributes#" item="myKey">
    <cfoutput>Value of #myKey# is #structFind(foo.attributes, myKey)#</cfoutput>
</cfloop>

Refer to the LiveDocs' structure looping page for more details.

Upvotes: 0

Ben Doom
Ben Doom

Reputation: 7885

Assuming your variable name is "foo", you can access the name like this

foo.attributes.name

Structures are simply accessed via dot notation.

Upvotes: 6

bragboy
bragboy

Reputation: 35542

If you want to simply dump this structure, use a simple XML and store it in a CLOB or BLOB field. But if you want to perform operations such as search, frequent changes to the data, then its better you consider tree structures.

If you are using Oracle, take a look at CONNECT BY PRIOR, this makes you store values in the database directly as rows and later query them and load into a tree structure.

The gist here is you should both be able to store and retrieve data as if you are dealing with a simple TREE data structure.

Upvotes: 1

Related Questions