queryAddColumn

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
Required

column_name string
Required

datatype string

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

array_name array
Required

Links more information about queryAddColumn

Examples
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", []);
writeDump(books);

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

Fork me on GitHub