A typical ColdFusion Gateway
As our introduction into Gateway objects, we will create an object that will allow us to query our database table of users to retrieve a large query of all records stored, as well as methods that will allow us to search or 'filter' the data to return specific records based upon criteria, suitable for a search interface.
Firstly, let's create a new ColdFusion template file and save it with the name listUsers.cfm
. This page will form part of our user management application, and will list all Users currently stored within the database.
Let's add the following code into the listUsers.cfm
file:
<cfquery name="qlistUsers" datasource="CFOOP" username="<username>" password="<password>"> SELECT ID, firstName, lastName, username, password, emailAddress FROM tbl_Users ORDER BY firstName </cfquery> <cfdump var="#qlistUsers#" label="qlistUsers" /> <h3>List All Users</h3> <ul> <cfoutput query="qlistUsers"> <li><...