
47
DEVELOPING
COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Las
t
upda
te
d 8/5/2010
For example, the following line creates a new variable, myStructure2, that is a reference to the same structure as the
myStructure variable:
<cfset myStructure2=myStructure>
When you change the contents of myStructure2, you also change the contents of myStructure. To copy the contents
of a structure, use the ColdFusion
Duplicate
function, which copies the contents of structures and other complex
data types.
Structure key names can be the names of complex data objects, including structures or arrays. This lets you create
arbitrarily complex structures.
For more information on using structures, see “
Using Arrays and Structures
” on page 82.
Queries
A
query object
, sometimes referred to as a query, query result, or recordset, is a complex ColdFusion data type that
represents data in a set of named columns, like the columns of a database table. Many tags can return data as a query
object, including the following:
•
cfquery
•
cfdirectory
•
cfhttp
•
cfldap
•
cfpop
•
cfprocresult
In these tags, the
name
attribute specifies the query object’s variable name. The
QueryNew
function also creates query
objects.
When you assign a query to a new variable, ColdFusion does
not
copy the query object. Instead, both names point to
the same recordset data. For example, the following line creates a new variable, myQuery2, that references the same
recordset as the myQuery variable:
<cfset myQuery2 = myQuery>
If you make changes to data in myQuery, myQuery2 also shows those changes.
You reference query columns by specifying the query name, a period, and the column name; for example:
myQuery.Dept_ID
When you reference query columns inside tags, such as
cfoutput
and
cfloop
, in which you specify the query name
in a tag attribute, you do not have to specify the query name.
You can access query columns as if they are one-dimensional arrays. For example, the following line assigns the
contents of the Employee column in the second row of the myQuery query to the variable myVar:
<cfset myVar = myQuery.Employee[2]>
Note:
You cannot use array notation to reference a row (of all columns) of a query. For example, myQuery[2] does not
reference the second row of the myQuery query object.
Working with structures and queries
Because structure variables and query variables are references to objects, the rules in the following sections apply to
both types of data.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...