View comments | RSS feed

QueryNew

Description

Creates an empty query.

Return value

An empty query with a set of columns, or an empty query.

Category

Query functions

Syntax

QueryNew(columnlist)

See also

QueryAddColumn, QueryAddRow, QuerySetCell

Parameters

Parameter Description
columnlist
A string or a variable that contains one. Delimited list of columns, or an empty string.

Usage

If you specify an empty string, you can add a column to the query and populate its rows with the contents of a one-dimensional array using QueryAddColumn.

Example

<h3>QueryNew Example</h3>
<p>We will construct a new query with two rows:
<cfset myQuery = QueryNew("name, address, phone")>
<!--- make some rows in the query --->
<cfset newRow  = QueryAddRow(MyQuery, 2)>
<!--- set the cells in the query --->
<cfset temp = QuerySetCell(myQuery, "name", "Fred", 1)>
<cfset temp = QuerySetCell(myQuery, "address", "9 Any Lane", 1)>
<cfset temp = QuerySetCell(myQuery, "phone", "555-1212", 1)>
<cfset temp = QuerySetCell(myQuery, "name", "Jane", 2)>
<cfset temp = QuerySetCell(myQuery, "address", "14 My Street", 2)>
<cfset temp = QuerySetCell(myQuery, "phone", "555-1444", 2)>
<!--- output the query --->
<cfoutput query = "myQuery">
<pre>#name#  #address#  #phone#</pre>
</cfoutput>  
To get any element in the query, we can output it individually
<cfoutput>
  <p>#MyQuery.name[2]#'s phone number: #MyQuery.phone[2]#
</cfoutput>

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


fusebox_steve said on Jul 1, 2002 at 10:29 PM :
Why can't you nest one query inside of another?
TheoPeters said on Aug 29, 2003 at 10:17 AM :
Why is this the only list in CFML that can only be comma separated?
QueryNew should have an optional argument for the list delimiter.
TheCoolLion said on Sep 27, 2005 at 3:52 PM :
QueryNew allows the labels to be added in a comma separated list,
Why is not possible to add the rows in the same way?

<cfset myQuery = QueryNew("name, address, phone")>

<cfset temp=QueryAddRow("Fred,9 any lane,551-1212")>

or something like that.

It would be more intuitive and programmer friendly.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt256.htm