Accessing And Retrieving Data - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
<cftransaction>
<cfquery name="qInsEmp" datasource="cfdocexamples">
INSERT INTO Employees (FirstName,LastName,EMail,Phone,Department)
VALUES ('Simon', 'Horwith', 'SHORWITH','(202)-797-6570','Research and Development')
</cfquery>
<cfquery name="qGetID" datasource="cfdocexamples">
SELECT MAX(Emp_ID) AS New_Employee
FROM Employees
</cfquery>
</cftransaction>

Accessing and Retrieving Data

Several ColdFusion tags provide a way to retrieve data from a database and work with query data. Use the
to query a data source, the
cfoutput
reduce security risks in your applications.
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 run time—as your users interact with pages in their browsers.
For ColdFusion developers, the term data source can refer to 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.
Here, you build a query to retrieve data from the cfdocexamples data source.
To query a database, use:
• ColdFusion data sources
• The
tag
cfquery
• SQL commands
Retrieving data
You can query databases to retrieve data at run time. The retrieved data, called the recordset, is stored on that page as
a query object. A query object is a special entity that contains the recordset values, plus RecordCount, CurrentRow,
ColumnList, SQL, Cached, and SQLParameter query variables. You specify the name of the query object in the
attribute of the
tag. The query object is often called simply the query.
cfquery
The following is a simple
cfquery
<cfquery name = "GetSals" datasource = "cfdocexamples">
SELECT * FROM Employee
ORDER BY LastName
</cfquery>
tag to output the query results to a web page, and the
tag:
Last updated 1/20/2012
tag
cfquery
tag to help
cfqueryparam
name
410

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents