Adds a column to a query and populates its rows with the
contents of a one-dimensional array. Pads query columns,
if necessary, to ensure that all columns have the same number
of rows.
queryAddColumn(query, column_name [, datatype], array_name)
→ returns numeric
someQuery.addColumn(column_name [, datatype], array_name)
Integer
Bigint
Double
Decimal
Varchar
Binary
Bit
Time
Date
Timestamp
<!--- Make a query. --->
<cfset myQuery = queryNew("")>
<!--- Create an array. --->
<cfset FastFoodArray = arrayNew(1)>
<cfset FastFoodArray[1] = "French Fries">
<cfset FastFoodArray[2] = "Hot Dogs">
<cfset FastFoodArray[3] = "Fried Clams">
<cfset FastFoodArray[4] = "Thick Shakes">
<!--- Use the array to add a column to the query. --->
<cfset nColumnNumber = queryAddColumn(myQuery, "FastFood", "VarChar", FastFoodArray)>
<cfdump var="#myQuery#" />
add a column to a query using member syntax
books = queryNew("id,title", "integer,varchar");
books.addColumn("author", "varchar", []);
writeDump(books);
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.