the singularity of being and nothingness
Quick ColdFusion Goodness: Case-Sensitive Column Name List
Ok, so I should be working on my novel right now, but I thought I’d share a quick ColdFusion tip (not original with me).
Imagine that you want to use the column names from your query to populate the header row in an Excel file. If you use myquery.columnlist, you’ll get the list of column names, but they’ll be in alphabetical order…and in all caps.
An easy way around this is–surprise, surprise–to tap into some of the Java beneath the query object. The following will get you the column list as an array, in the proper order, and respect the column name casing:
columns = myquery.getMeta().getcolumnlabels()
Ok, back to the book! 🙂
Print article | This entry was posted by existdissolve on November 5, 2010 at 10:25 pm, and is filed under ColdFusion. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 14 years ago
The example above should be: query.getMetaData().getColumnLabels() I think.
about 14 years ago
Hi Erik–
Interesting, looks like both versions work: query.getMeta.getColumnLabels() and query.getMetaData.getColumnLabels()
about 10 years ago
Just stumbled across this today. Finally! This bothered me oh-so-much having all uppercase keys in my JS. 🙂