So I have a string that was constructed in a different file being passed into a query as a global variable that I need to bind (legacy code):
<cfset queryString="((playerID=1223) OR playerID=1224))">
<cfquery name="testQuery">
SELECT *
FROM teamRoster
WHERE teamID = 9876
AND <cfqueryparam value="#queryString#" cfsqltype="CF_SQL_VARCHAR">
</cfquery>
Is there a way to use cfqueryparam for query strings here? Or is there a different way to protect myself from sql injection here? Thanks for your help!
You cannot use cfqueryparam for query strings. It can only be used for those things sql allows you to paramaterize (basically, just literals like strings or numbers). They can't be bound to keywords or field names, let alone complex clauses.
FWIW, this is a SQL limitation, not a ColdFusion issue.