MACROMEDIA COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX Getting Started page 125

Building coldfusion mx applications
Table of Contents

Advertisement

Limiting the number of result rows
Each of the SQL statements in the preceding table returns a result set of trips rows. The result set
can range from zero to any number of rows. The Navigation Action page must limit the result set
count to 1, because only the initial row in the result set appears on the Trip Detail page.
ColdFusion provides the
limits the number of result rows returned from the database. To show only a single row at a time
in the Trip Detail page, set
To build the Navigation Action page:
Create a blank file.
1.
Enter the following code in the blank file:
2.
<!---
NAVIGATION BUTTONS --->
<cfquery name="TripQuery" datasource="CompassTravel" maxrows="1">
SELECT tripID FROM trips
<cfif IsDefined("Form.btnPrev.X")>
WHERE tripID < #Form.RecordID#
ORDER BY tripID DESC
<cfelseif IsDefined("Form.btnNext.X")>
WHERE tripID > #Form.RecordID#
ORDER BY tripID
<cfelseif IsDefined("Form.btnFirst.X")>
ORDER BY tripID
<cfelseif IsDefined("Form.btnLast.X")>
WHERE tripID > #Form.RecordID#
ORDER BY tripID DESC
</cfif>
</cfquery>
<cfif TripQuery.RecordCount is 1>
<cflocation url="tripdetail.cfm?ID=#TripQuery.tripID#">
<cfelse>
<cflocation url="tripdetail.cfm?ID=#Form.RecordID#">
</cfif>
Save the file as navigationaction.cfm in the my_app directory.
3.
Note: In previous lessons, you adhered to good coding practices by putting queries in ColdFusion
components. To optimize performance, and because the Navigation Action page contains only a
query, the page is a ColdFusion page rather than a CFC. For more information about code reuse, see
Chapter 8, "Creating ColdFusion Elements" in ColdFusion MX Developer's Guide.
attribute for the
maxRows
to 1.
maxRows
tag for this purpose. This attribute
cfquery
Exercise 1: Enabling users to browse trip details
125

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents