Converting a database query to a WDDX packet using ColdFusion
Readability
Converting a database query to a WDDX packet using ColdFusion
The following example shows how you can convert a database query to a XML WDDX packet using ColdFusion and the <CFWDDX> tag.
SELECT A.ARTISTID, A.FIRSTNAME, A.LASTNAME, A.ADDRESS, A.CITY, A.STATE
FROM ARTISTS A
#xmlFormat(artistsWDDX)#
And the output of the <CFOUTPUT> tag is as follows:
1.0 2.0 3.0 4.0 5.0 Aiden Austin Elicia Jeff Lori Donolan Weber Kim Baclawski Johnson 352 Corporate Ave. 25463 Main Street, Suite C 2523 National Blvd 903 Boardwalk Ave 6462 Cowtown Rd Denver Berkeley Los Angeles Hollywood Pierre CO CA CA FL SD
The following example shows how you can convert a database query to a XML WDDX packet using ColdFusion and the <CFWDDX> tag.
<cfquery name="getArtists" datasource="cfartgallery" maxRows="5"> SELECT A.ARTISTID, A.FIRSTNAME, A.LASTNAME, A.ADDRESS, A.CITY, A.STATE FROM ARTISTS A </cfquery> <cfwddx action="cfml2wddx" input="#getArtists#" output="artistsWDDX" /> <cfoutput>#xmlFormat(artistsWDDX)#</cfoutput> |
And the output of the <CFOUTPUT> tag is as follows:
<wddxPacket version='1.0'> <header/> <data> <recordset rowCount='5' fieldNames='ARTISTID,FIRSTNAME,LASTNAME,ADDRESS,CITY,STATE' type='coldfusion.sql.QueryTable'> <field name='ARTISTID'> <number>1.0</number> <number>2.0</number> <number>3.0</number> <number>4.0</number> <number>5.0</number> </field> <field name='FIRSTNAME'> <string>Aiden</string> <string>Austin</string> <string>Elicia</string> <string>Jeff</string> <string>Lori</string> </field> <field name='LASTNAME'> <string>Donolan</string> <string>Weber</string> <string>Kim</string> <string>Baclawski</string> <string>Johnson</string> </field> <field name='ADDRESS'> <string>352 Corporate Ave.</string> <string>25463 Main Street, Suite C</string> <string>2523 National Blvd</string> <string>903 Boardwalk Ave</string> <string>6462 Cowtown Rd</string> </field> <field name='CITY'> <string>Denver</string> <string>Berkeley</string> <string>Los Angeles</string> <string>Hollywood</string> <string>Pierre</string> </field> <field name='STATE'> <string>CO</string> <string>CA</string> <string>CA</string> <string>FL</string> <string>SD</string> </field> </recordset> </data> </wddxPacket>
One Response to Converting a database query to a WDDX packet using ColdFusion
Leave a Reply Cancel reply
Recent Posts
- Toggling the overview panel on a CFMAP tag in ColdFusion
- Listening for map errors on the CFMAP tag in ColdFusion
- Converting a database query to a WDDX packet using ColdFusion
- Toggling which columns are displayed from a database query using the CFDUMP tag in ColdFusion
- Dynamically adding columns to a database query using ColdFusion
- Adding the values in a database query column in ColdFusion
- Getting started with Arrays in ColdFusion
- Converting numbers between base 10 and base 16 using ColdFusion
- Getting started with Lists in ColdFusion
- Displaying a database query in a grid using the CFGRID tag in ColdFusion
Archives
- November 2010 (63)
- October 2010 (13)
Books
Categories
- Basics (4)
- CFAJAXIMPORT (1)
- CFAPPLICATION (1)
- CFCOMPONENT (1)
- CFDUMP (4)
- CFFEED (5)
- CFFILE (1)
- CFFORM (2)
- CFFUNCTION (1)
- CFARGUMENT (1)
- CFRETURN (1)
- CFHTTP (3)
- CFIF (1)
- CFELSE (1)
- CFIMAGE (3)
- CFINVOKE (1)
- CFINVOKEARGUMENT (1)
- CFLAYOUT (1)
- CFLAYOUTAREA (1)
- CFLOCATION (1)
- CFLOOP (6)
- CFMAP (10)
- CFMAPITEM (1)
- CFMEDIAPLAYER (11)
- CFOBJECT (1)
- CFOUTPUT (1)
- CFPARAM (1)
- CFPOD (4)
- CFQUERY (11)
- CFSCRIPT (2)
- CFTABLE (1)
- CFCOL (1)
- CFTRY (1)
- CFCATCH (1)
- CFWDDX (1)
- CFXML (1)
- CGI (2)
- jQuery (2)
- Uncategorized (6)
Tags
action arrayAppend() arrayAvg() arrayLen() arraySum() ceiling() centerAddress CGI ColdFusion.Map ColdFusion.Mediaplayer collapsible condition createDate() datasource dateAdd() dateFormat() delimters firstRowAsHeaders fix() format from hideBorder index jQuery listToArray() maxRows name onLoad onStart output pi() query querySetCell() recordCount round() setCenter() source step title to top type url valueList() xmlVar




Once you have the WDDX in an XML format, what else might you do with it?