Preservesinglequotes - MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE Reference

Cfml language reference
Hello, I am your AI assistant. How can I help you?
Table of Contents

Advertisement

Chapter 2: ColdFusion Functions

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
<H3>PreserveSingleQuotes Example</H3>
<P>This is a useful function for creating lists of
information to return from a query.
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>
bgcolor="#FFFFD5">
In the following
479

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 4.5-CFML LANGUAGE and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion 4.5

Table of Contents