House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Alternative for using SQL bind parameters

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hi guys,
Helwig, Till Helge
06/08/12 04:07 A
If you're on CF9+, then you can do what you want:
Dan G. Switzer, II
06/08/12 07:48 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Helwig, Till Helge
06/08/2012 04:07 AM

Hi guys, I'm working on a very old CF application at the moment. When it was first created, apparently nobody cared about sanitizing SQL statements. There are lots of SQL queries in the code and most don't use <cfqueryparam>, which I would like to change whenever I stumble upon one of these. However, there is a slight problem: In many places the query statement is being assembled outside of <cfquery> by various functions and then there is only <cfquery ...>#sql#</cfquery> in the code. Is there any way to make CF use bind variables in SQL statements apart from <cfqueryparam>, which obviously is not allowed outside of <cfquery>? I'm thinking about the flexibility in Java where you can just use ":foo" in statement strings and then provide a parameter map to the query. And if there isn't...how do you deal with situations like this? Till Helge

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dan G. Switzer, II
06/08/2012 07:48 AM

If you're on CF9+, then you can do what you want: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSe9cbe5cf462523a0693d5dae123bcd28f6d-7ffb.html You can also duplicate this concept in earlier versions of ColdFusion. I actually built an implementation for CF8 (probably would work in CF7 too) that also fixed some of the bugs/issues w/the CF9 implementation due to how they parse out the params (but it uses the same syntax.) Unfortunately, I can't share the code, but the basic idea is you just parse the SQL statement and then inside a <cfquery> statement you walk through the parsed string, outputting the straight text or implementing <cfqueryparam /> when you come to a parameter statement. -Dan On Fri, Jun 8, 2012 at 4:06 AM, Helwig, Till Helge <till.helwig@saxsys.de>wrote: ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 21, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference