I'm working a CFC web service where I want to return a JSON string; I don't
necessarily know my table's column names ahead of time. I am able to pull
out the table's column names and am trying to use them as my struct's node
names. When I try to dump them out, I get the string "IDX" rather than the
actual struct.
<cfset LOCAL = ArrayNew(1)>
<cfset cnt = 1>
<cfquery name="getColNames" datasource="foo">
SELECT column_name
from INFORMATION_SCHEMA.Columns
where table_name = 'users'
order by column_name
</cfquery>
<cfset sColNames = valuelist(getColNames.column_name)>
<cfquery name="getDis" datasource="foo">
SELECT * FROM users
where emplid in (#emplids#)
ORDER BY empname
</cfquery>
<cfloop query="getDis">
<cfset LOCAL[cnt] = structnew()>
<cfloop list=#sColNames# index="idx">
<cfset LOCAL[cnt].idx = evaluate("getDis."& idx)>
</cfloop>
<cfset cnt = cnt + 1>
</cfloop>
Any ideas?
tia,
- Joe
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318498
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4