Name

PreserveSingleQuotes

Synopsis

PreserveSingleQuotes(variable)

Returns variable without escaping single quotation marks. PreserveSingleQuotes( ) keeps ColdFusion from automatically escaping single quotation marks within dynamically set variables. The PreserveSingleQuotes( ) function is most often used with SQL statements when it is necessary to pass dynamically generated values. Example:

<CFSET Names = "'Pere Money','Mark Edward','Marcel Haney'">

<CFQUERY NAME="GetRecords" DATASOURCE="ProgrammingCF">
         SELECT * FROM EmployeeDirectory
         WHERE Name IN (#PreserveSingleQuotes(Names)#)
</CFQUERY>

<CFOUTPUT>#GetRecords.RecordCount# record(s) found.</CFOUTPUT>

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.