Add Comment
Select like with cfqueryparam
ColdFusion Tutorial #41
cfqueryparam is a fantastic part of ColdFusion it helps protect from SQL injection and improves performance. It is a little differnt to use then normal querys and one question that often gets asked is "How do I do a like clause with cfqueryparam?". Well here is the answer. line 4 of search_result.cfm <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="%#FORM.keyword#%">
Remember the % % goes around the varibale ( or plain text string )
demo.cfm
Query the database for some sample data and show a simple form.search_results.cfm
Using the data posted retrive the results from the database that are "like" the term entered.Demo
See this code running!
Download
Download this code as a zip!
Comments
There are no comments!Click button to add a comment
Author
John Barrett