Chapter 2: ColdFusion Functions
479
PreserveSingleQuotes
Prevents ColdFusion from automatically “escaping” single quotes contained in
variable.
Syntax
PreserveSingleQuotes
(
variable)
variable
Variable containing the string for which single quotes are preserved.
Usage
PreserveSingleQuotes is useful in SQL statements.
Example
<!--- This example shows the use of PreserveSingleQuotes --->
<HTML>
<HEAD>
<TITLE>
PreserveSingleQuotes Example
</TITLE>
</HEAD>
<basefont face="Arial, Helvetica" size=2>
<body bgcolor="#FFFFD5">
<H3>PreserveSingleQuotes Example</H3>
<P>This is a useful function for creating lists of
information to return from a query. In the following
example, we pick the list of Centers in Suisun, San Francisco,
and San Diego, using the SQL grammar IN to modify a WHERE
clause rather than looping through the result set after
the query is run.
<CFSET List = "’Suisun’, ’San Francisco’, ’San Diego’">
<CFQUERY NAME="GetCenters" DATASOURCE="cfsnippets">
SELECT Name, Address1, Address2, City, Phone
FROM Centers
WHERE City IN (#PreserveSingleQuotes(List)#)
</CFQUERY>
<P>We found <CFOUTPUT>#GetCenters.RecordCount#</CFOUTPUT> records.
<CFOUTPUT query="GetCenters">
<P>#Name#<BR>
#Address1#<BR>
<CFIF Address2 is not "">#Address2#</CFIF>
#City#<BR>
#Phone#<BR>
</CFOUTPUT>
</BODY>
</HTML>
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...