I am using CFWheels for my project.
In my controller I have sql query string;
r_query = "SELECT MAX(column)
FROM user_checklist
INNER JOIN rooms
ON user_checklist.RID = rooms.ID
INNER JOIN buildings
ON rooms.BID = buildings.ID
INNER JOIN tb inspectors
ON user_checklist.INSPID = inspectors.ID
GROUP BY user_checklist.cdate, user_checklist.rid";
if(StructKeyExists(date_key, "expression") AND StructKeyExists(date_key, "value"))
{
r_query &= " HAVING #date_key.expression# '#date_key.value#'";
}
In My View I have the CFQuery tag;
<cfoutput>
<cfquery datasource="local" name="total_records">
#PreserveSingleQuotes(sql_query)#
</cfquery>
</cfoutput>
As you can see I am not using CFQueryParam for binding and preventing SQL Injection. How can I better this query in my controller, so it would have some sort of place holder like '?' or ":param", which can then be binded in the view? I basically want to prevent SQL inject in the query.
Thank you