System information
78 Chapter 7: Lesson 4: Building Dynamic Queries
</cfquery>
<cfreturn TripResult>
</cffunction>
4.
Add the highlighted code to the cfquery block to use the dynamically built WHERE clause in
the query:
<cfquery name="TripResult" datasource="CompassTravel">
SELECT tripID, tripName, tripLocation, departureDate,
returnDate, price FROM trips
WHERE #PreserveSingleQuotes(WhereClause)#
</cfquery>
5.
Save the file.
Let Dreamweaver do it
You can use the Dreamweaver Extensions to create the CFC query.
To construct the query with Dreamweaver:
1.
Click the Bindings tab.
2.
Click the + button.
3.
Select Record set (Query).
4.
In the Name text box, enter Tr i p R e s u l t .
5.
Click the New Function button.
6.
In the New function name text box, enter getTripsFromForm and click OK.
7.
From the Data source list, select CompassTravel.
8.
From the Tables list, select trips.
9.
Click the Selected radio button.
10.
Select tripName, tripLocation, departureDate, returnDate, price, and tripID.
11.
Click OK.
12.
Return to Step 3 in the “To add the new query to the CFC:” section.