O'Reilly logo

Railo 3 Beginner’s Guide by Mark Drew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - running queries against our database

The magic for running a lot of queries with Railo stems from the <cfquery> tag. This is a very versatile tag that allows you to run queries to a data source. Remember, we queried the database to get our list of employees? Let's do that in CFML to see how easy it is to do.

<cfquery name="getEmployees" datasource="railobook">
SELECT * FROM employee
</cfquery>
<cfloop query="getEmployees">
<cfoutput>#FirstName# #LastName# <br></cfoutput>
</cfloop>>

We use the <cfquery> tag, setting the name of the results to getEmployees by putting that in the name attribute. We also use the datasource attribute to say we are going to use the datasource we setup, called railobook previously.

Then we put the SQL ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required