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 MX, 2nd Edition 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.