Adobe COLDFUSION 9 Manual page 53

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Multiple references to an object
When multiple variables reference a structure or query object, the object continues to exist as long as at least one
reference to the object exists. The following example shows how this works:
<cfscript> depts = structnew();</cfscript>
<cfset newStructure=depts>
<cfset depts.John="Sales">
<cfset depts=0>
<cfoutput>
#newStructure.John#<br>
#depts#
</cfoutput>
This example displays the following output:
Sales
0
After the
<cfset depts=0>
the value 0. However, the variable newStructure still refers to the original structure object.
Assigning objects to scopes
You can give a query or structure a different scope by assigning it to a new variable in the other scope. For example,
the following line creates a server variable, Server.SScopeQuery, using the local myquery variable:
<cfset Server.SScopeQuery = myquery>
To clear the server scope query variable, reassign the query object, as follows:
<cfset Server.SScopeQuery = 0>
This line deletes the reference to the object from the server scope, but does not remove any other references that can
exist.
Copying and duplicating objects
You can use the
Duplicate
affect the original.
Using a query column
When you are not inside a tag such as
column as an array. However, query column references do not always behave as you might expect. This section
explains the behavior of references to query columns using the results of the following
<cfquery dataSource="cfdocexamples" name="myQuery">
SELECT FirstName, LastName
FROM Employee
</cfquery>
To reference elements in a query column, use the row number as an array index. For example, both of the following
lines display the word "ben":
<cfoutput> #myQuery.Firstname[1]# </cfoutput><br>
<cfoutput> #myQuery["Firstname"][1]# </cfoutput><br>
tag executes, the depts variable does not reference a structure; it is a simple variable with
function to make a true copy of a structure or query object. Changes to the copy do not
,
cfloop
cfoutput
Last updated 8/5/2010
, or
that has a
cfmail
query
attribute, you can treat a query
tag in its examples:
cfquery
48

Advertisement

Table of Contents
loading

Table of Contents