CFLib.org – Common Function Library Project

getQueryColumns(theQuery)

Last updated January 11, 2011

Version: 1 | Requires: ColdFusion MX | Library: DatabaseLib

 
Rated 1 time(s). Average Rating: 5.0

Description:
Retrieve a list of column names in the order as defined by SQL for use with CFSpreadsheet (generating a header row) and other loop functions.

Return Values:
Returns a list.

Example:

view plain print about
<cfquery name="GetOrders">
SELECT orderid, customerfirstname, customerlastname, total
FROM orders
ORDER BY orderid
</cfquery>

<CFSET ColumnList = getQueryColumns(GetOrders)>

Parameters:

Name Description Required
theQuery Query object to examine. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Returns list of query columns in order as defined by SQL query.
 * 
 * @param theQuery      Query object to examine. (Required)
 * @return Returns a list. 
 * @author James Moberg (james@ssmedia.com) 
 * @version 1, January 11, 2011 
 */

function getQueryColumns(theQuery){
    if(isQuery(theQuery)) return arraytoList(theQuery.getMeta().getColumnLabels());
    else return '';
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson