CFLib.org – Common Function Library Project

getQueryColumns(theQuery)

Last updated January 11, 2011

author

James Moberg

Version: 1 | Requires: CF6 | Library: DatabaseLib

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:

<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:

/**
 * 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 '';
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson