Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 97

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
<!--- Do the query --->
<cfquery name="test" datasource="cfdocexamples">
SELECT Emp_ID, LastName, FirstName, Email
FROM Employees
</cfquery>
<!--- Declare the array --->
<cfset myarray=arraynew(2)>
<!--- Populate the array row by row --->
<cfloop query="test">
<cfset myarray[CurrentRow][1]=Emp_ID>
<cfset myarray[CurrentRow][2]=LastName>
<cfset myarray[CurrentRow][3]=FirstName>
<cfset myarray[CurrentRow][4]=Email>
</cfloop>
<!--- Now, create a loop to output the array contents --->
<cfset total_records=test.recordcount>
<cfloop index="Counter" from=1 to="#Total_Records#">
<cfoutput>
ID: #MyArray[Counter][1]#,
LASTNAME: #MyArray[Counter][2]#,
FIRSTNAME: #MyArray[Counter][3]#,
EMAIL: #MyArray[Counter][4]# <br>
</cfoutput>
</cfloop>
This example uses the query object built-in variable CurrentRow to index the first dimension of the array.
Array functions
The following functions are available for creating, editing, and handling arrays:
Function
Description
Appends an array element to the end of a specified array.
ArrayAppend
ArrayAvg
Returns the average of the values in the specified array.
Deletes all data in a specified array.
ArrayClear
ArrayDeleteAt
Deletes an element from a specified array at the specified index and resizes the array.
ArrayInsertAt
Inserts an element (with data) in a specified array at the specified index and resizes the array.
ArrayIsDefined
Returns True if the specified array is defined.
ArrayIsEmpty
Returns True if the specified array is empty of data.
Returns the length of the specified array.
ArrayLen
ArrayMax
Returns the largest numeric value in the specified array.
Returns the smallest numeric value in the specified array.
ArrayMin
ArrayNew
Creates an array of specified dimension.
Adds an array element to the beginning of the specified array.
ArrayPrepend
ArrayResize
Resets an array to a specified minimum number of elements.
Last updated 1/20/2012
92

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents