Prevents ColdFusion from automatically "escaping" single quotes contained in variable.
PreserveSingleQuotes(variable)
Variable containing the string for which single quotes are preserved.
PreserveSingleQuotes is useful in SQL statements.
<!--- 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>