| Contents > CFML Reference > ColdFusion Functions > QueryNew |
|
|
|
|
||
Creates an empty query (query object).
An empty query with a set of named columns, or an empty query.
QueryNew(columnlist)
QueryAddColumn, QueryAddRow, QuerySetCell
Parameter |
Description |
|---|---|
columnlist |
A string or a variable that contains one. Delimited list of column names, or an empty string. |
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.
<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>
|
|
||
| Contents > CFML Reference > ColdFusion Functions > QueryNew |
|
|
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functa57.htm
Comments
mossy_77 said on Jul 22, 2004 at 2:14 AM : No screen name said on Feb 3, 2005 at 12:35 PM : Cal22 said on May 17, 2005 at 6:19 PM :