Simone
04/15/2022, 3:06 PM<cfif len(trim(arguments.sSearch))>
AND
(
<cfloop list="#arguments._listColumns#" index="thisColumn">
<cfif thisColumn neq listFirst(arguments._listColumns)>
OR
</cfif>
#thisColumn# LIKE '%#trim(arguments.sSearch)#%'
</cfloop>
)
</cfif>
Michael Schmidt
04/15/2022, 3:11 PMMichael Schmidt
04/15/2022, 3:16 PMDECLARE @sSearch varchar(max) = <cfqueryparam cfsqltype="cf_sql_varchar" value="%#Trim(arguments.sSearch)#%">
<cfif len(trim(arguments.sSearch))>
AND
(
<cfloop list="#arguments._listColumns#" index="thisColumn">
<cfif thisColumn neq listFirst(arguments._listColumns)>
OR
</cfif>
#thisColumn# LIKE @sSearch
</cfloop>
)
</cfif>
Michael Schmidt
04/15/2022, 3:16 PMScott Bennett
04/15/2022, 3:21 PMSimone
04/15/2022, 3:30 PMMichael Schmidt
04/15/2022, 3:35 PMSET @sSearch varchar(max) = <cfqueryparam cfsqltype="cf_sql_varchar" value="%#Trim(arguments.sSearch)#%">
Michael Schmidt
04/15/2022, 3:35 PMScott Bennett
04/15/2022, 3:41 PM<cfset goodcolumnlist = "column1,column2,col3">
<cfsavecontent variable="somefilters">
<cfif len(trim(arguments.sSearch))>
AND
(
<cfset useOr = "">
<cfloop list="#arguments._listColumns#" index="thisColumn">
<cfif listfindnocase(thisColumn, goodcolumnlist)>
#useOr# #thisColumn# LIKE @sSearch
<cfset useOr = "OR">
</cfif>
</cfloop>
)
</cfif>
</cfsavecontent>
Scott Bennett
04/15/2022, 3:49 PMAdam Cameron
i am trying to use cfqueryparam in rereplace to replace the value using cfqueryparam
any sample how can i do itSeriously... what??? What is that supposed to mean? Do you ever re-read your questions before you press send and think "will this make any sense to anyone other than me?"
Scott Bennett
04/15/2022, 4:43 PMDavid Buck
04/18/2022, 1:53 PM<cfsavecontent>
to create a SQL string, and you want to know how to parameterize the client variables since you can't use <cfqueryparam>
outside of <cfquery>
. Right? You might want to consider using the queryExecute() function instead of <cfquery>
for this sort of thing. The queryExecute function allows you to define the parameters outside of the query string. Below is an example that I copied from the Adobe docs. It contains 1 parameter, named country.
QueryExecute("select from Employee where country=:country and citizenship=:country", {country='USA'});
The first argument is the query string, which uses a placeholder variable (:country) for the parameter, and the second argument is a struct in which the parameter is actually defined. Read the full documentation for more info.