
517
DEVELOPING
COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Las
t
upda
te
d 8/5/2010
For example, assume a document field named SOURCE includes the following values:
•
Computer
•
Computerworld
•
Computer Currents
•
PC Computing
To locate documents whose source is Computer, enter the following:
SOURCE <MATCHES> computer
To locate documents whose source is Computer, Computerworld, and Computer Currents, enter the following:
SOURCE <MATCHES> computer*
To locate documents whose source is Computer, Computerworld, Computer Currents, and PC Computing, enter the
following:
SOURCE <MATCHES> *comput*
For an example of ColdFusion code that uses the CONTAINS relational operator, see “
Field searches
” on page 523.
You can use the SUBSTRING operator to match a character string with data stored in a specified data source. In the
example described here, a data source called TEST1 contains the table YearPlaceText, which contains three columns:
Year, Place, and Text. Year and Place make up the primary key. The following table shows the TEST1 schema:
Operator
Description
Example
CONTAINS
Selects documents by matching the word or phrase that you specify
with the values stored in a specific document field. Documents are
selected only if the search elements specified appear in the same
sequential and contiguous order in the field value.
•
In a document field named TITLE, to retrieve
documents whose titles contain music, musical,
or musician, search for
TITLE <CONTAINS> Musi*
.
•
To retrieve CFML and HTML pages whose meta
tags contain Framingham as a content word,
search for
KEYWORD <CONTAINS> Framingham
.
MATCHES
Selects documents by matching the query string with values stored in
a specific document field. Documents are selected only if the search
elements specified match the field value exactly. If a partial match is
found, a document is not selected. When you use the MATCHES
operator, you specify the field name to search, and the word, phrase,
or number to locate. You can use ? and * to represent individual and
multiple characters, respectively, within a string.
For examples, see the text immediately following
this table.
STARTS
Selects documents by matching the character string that you specify
with the starting characters of the values stored in a specific
document field.
In a document field named REPORTER, to retrieve
documents written by Clark, Clarks, and Clarkson,
search for
REPORTER <STARTS> Clark
.
ENDS
Selects documents by matching the character string that you specify
with the ending characters of the values stored in a specific
document field.
In a document field named OFFICER, to retrieve
arrest reports written by Tanner, Garner, and Milner,
search for
OFFICER <ENDS> ner
.
SUBSTRING
Selects documents by matching the query string that you specify
with any portion of the strings in a specific document field.
In a document field named TITLE, to retrieve
documents whose titles contain words such as
solution, resolution, solve, and resolve, search for
TITLE <SUBSTRING> sol
.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...