Using the cfindex tag in ColdFusion MX
To populate a collection with the contents of the query results, you can now use the
with the
attribute and
query
information from the
When you use
type = "file"
filenames or file paths from the
actions use the filenames or file paths to execute their code.
The following table shows a sample database for an application on a Windows server:
BookID URL
bookid1
url1
bookid2 url2
bookid3 url3
file
http://localhost/cfdocs/snippets
path1
http://localhost/cfdocs/snippets/
path2
http://localhost/cfdocs/
cfmlsyntaxcheck
You can populate a collection using either of the following scripts:
•
Populate the
snippets
database:
<CFQUERY NAME = "bookquery"
DATASOURCE = "book">
SELECT * FROM book where bookid='file'
</CFQUERY>
<CFOUTPUT QUERY = "bookquery">
#url#,#description# <BR>
<cfindex collection = "snippets" action = "update" type = "file"
query = "bookquery" key = "description" URLPath = "url">
</CFOUTPUT>
•
Populate the
snippets
database:
<CFQUERY NAME="bookquery"
DATASOURCE="book">
SELECT * FROM book where bookid='path1' or bookid='path2'
</CFQUERY>
<CFOUTPUT QUERY="bookquery">
#url#,#description# <BR>
<cfindex collection="snippets" action="update"
type="path" query="bookquery" key="description" URLpath="url" >
</CFOUTPUT>
22
Chapter 1: Migrating Applications from ColdFusion 5
type = "file"
attribute. You can also still use
key
or
type = "path"
attribute, and passes the query results to its actions. The
key
collection with files specified in the description column of the
collection with paths specified in the description column of the
or
, for all actions that require
type = "path"
type = "custom"
with a query, the
action
Title
Description
title1
description1
title2
description2
title3
description3
title4
c:\inetpub\wwwroot\cfdocs\snippets\f
ile.cfm
title5
c:\inetpub\wwwroot\cfdocs\snippets\
title6
c:\inetpub\wwwroot\cfdocs\
cfmlsyntaxcheck
tag
cfindex
.
attribute queries to get