> Of course a lot of this is academic anyway. Jochem is
> correct of course that much (perhaps all of this) of
> this is now handled (better) with CFQUERYPARAM.
> The PreserveSingleQuotes() function was one of the
> original functions (I believe all the way back to
> version 1.0).
> It made sense when it was created but it really only
> makes sense now if you can't, for some reason, use
> CFQUERYPARAM.
erm... I think you got that a little backwards. The purpose of
PreserveSingleQuotes() is to allow you to pass a sql statement or portion of
a sql statement as a variable into a query, i.e.
<cfset mywhereclause = "mycolumn='something'">
<cfquery ...>
SELECT * FROM mytable
WHERE #preservesinglequotes(mywhereclause)#
</cfquery>
cfqueryparam can't perform this function, because a sql variable can't be
used as a portion of this query -- without first trapping it in something
within the db like sp_executesql @mystatement or exec(@mystatement) ... So
queryparam doesn't change the purpose or frequency with which you would use
preservesinglequotes() at all... That being said, I rarely find any need to
use preservesinglequotes(); and you're right the answer to the original
question this thread started with probably lies with cfqueryparam and not
preservesinglequotes.
As an asside -- I remember that prior to my becoming involved with cf, the
syntax for cfquery was
<cfquery datasource="blah" sql="sql statement here">
So because it was an attribute and not an inner-text between an open and
close tag, the tendancy was to do what ASP developers do and create the
entire sql statement as a string and pass the string to the attribute, i.e.:
<cfquery sql="#mysqlstatement#"> in which case the only way to make the
statement work if the #mysqlstatement# variable contained something like
mycolumn='something' would be to use #preservesinglequotes(mysqlstatement)#.
Isaac
Certified Advanced ColdFusion 5 Developer
www.turnkey.to
954-776-0046
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm