32
Chapter 3 Querying a Database
Getting Information About Query Results
Each time you query a database with the
cfquery
tag, you get not only the data itself,
but also query properties, as described in the following table:
To output query data on your page:
1
Return to
emplist.cfm
in ColdFusion Studio.
2
Edit the file so that it appears as follows:
<html>
<head>
<title>Employee List</title>
</head>
<body>
<h1>Employee List</h1>
<cfquery name="EmpList" datasource="CompanyInfo">
SELECT FirstName, LastName, Salary, Contract
FROM Employee
</cfquery>
<cfoutput query="EmpList">
#FirstName#, #LastName#, #Salary#, #Contract#<br>
</cfoutput>
<br>
<cfoutput>
The query returned #EmpList.RecordCount# records.
</cfoutput>
</body>
</html>
3
Save the file as
emplist.cfm
.
4
View the page in a browser.
The number of employees now appears below the list of employees.
Note
The variable
cfquery.executionTime
contains the amount of time, in milliseconds,
it took for the query to complete. Do not prefix the variable name with the query
name.
Reviewing the code
Property
Description
RecordCount
The total number of records returned by the query.
ColumnList
A comma-delimited list of the query columns.
CurrentRow
The current row of the query being processed by
cfoutput
.
Summary of Contents for COLDFUSION 5-DEVELOPING
Page 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Page 58: ...38 Chapter 3 Querying a Database ...
Page 134: ...114 Chapter 7 Updating Your Database ...
Page 210: ...190 Chapter 10 Reusing Code ...
Page 232: ...212 Chapter 11 Preventing and Handling Errors ...
Page 238: ...218 Chapter 12 Using the Application Framework ...
Page 262: ...242 Chapter 12 Using the Application Framework ...
Page 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Page 320: ...300 Chapter 15 Indexing and Searching Data ...
Page 336: ...316 Chapter 16 Sending and Receiving E mail ...
Page 374: ...354 Chapter 18 Interacting with Remote Servers ...