User Guide

Table Of Contents
465
CHAPTER 20
Accessing and Retrieving Data
This chapter describes how to retrieve data from a database and work with query data. This
chapter also shows how to use the
cfquery tag to query a data source, and use the cfoutput tag
to output the query results to a web page. This chapter also describes how to use the
cfqueryparam tag to help reduce security risks.
Contents
Working with dynamic data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Retrieving data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Outputting query data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Getting information about query results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Enhancing security with cfqueryparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Working with dynamic data
A web application page is different from a static web page because it can publish data dynamically.
This can involve querying databases, connecting to LDAP or mail servers, and leveraging COM,
DCOM, CORBA, or Java objects to retrieve, update, insert, and delete data at runtime—as your
users interact with pages in their browsers.
For ColdFusion developers, the term data source can refer to a number of different types of
structured content accessible locally or across a network. You can query websites, LDAP servers,
POP mail servers, and documents in a variety of formats. Most commonly though, a database
drives your applications, and for this discussion a data source means the entry point from
ColdFusion to a database.
In this chapter, you build a query to retrieve data from the cfdocexamples data source. In
Windows, this data source connects to a Microsoft Access database (cfdocexamples.mdb
). In
UNIX, this data source connects to a PointBase database. In subsequent chapters in this manual,
you insert and update data in this database.