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

Member Function Syntax

someQuery.addColumn(column_name [, datatype], array_name)

Argument Reference

query query

column_name string

datatype string

Column data type.
  • Integer
  • Bigint
  • Double
  • Decimal
  • Varchar
  • Binary
  • Bit
  • Time
  • Date
  • Timestamp

array_name array

Links more information about queryAddColumn

Sample code invoking the queryAddColumn function

<!--- 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", []);

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub