So my real issue was that I wanted to super dynamically assemble the SQL and
then either execute it or do a variety of other things with it ( which I
won't go into ).
If you try to use cfqueryparam outside of a containing cfquery, ColdFusion
breaks.
So,
cfsavecontent
...cfqueryparam...
/cfsavecontent
if something
do something else with it
else
cfquery it
errored.
By "hacking cfquery", I mean that it suddently occured to me that you can do
this, instead of the other options:
cfquery
cfsavecontent
...cfqueryparam...
/cfsavecontent
if something
select false
else
#cfsavecontent#
/cfquery
if something
return cfsavecontent
else
return queryName
Note that you'll still need to not use cfqueryparam in cases where you won't
be executing the query ( and swap in the unprocessed values or placeholders
), but in my case that still dramatically reduced the code necessary to
support the multiple channels ( solved my problem ).
It's very hacky, but worked like a charm.
On Thu, Apr 16, 2009 at 2:40 PM, Dominic Watson <
[email protected]> wrote:
>
> > If so, does that mean my only option is writing a custom tag to simulate
> > cfquery and having it handle all of that stuff the same way cfquery does?
> (
> > Retrieve the datasource info from the adminapi, create and manage the
> > connection, call all of these execution methods and then translate their
> > results to a CFML query object, etc.
>
> It is so, but I think the option of creating the custom tag is both
> mildly barmy and not the only option. A possible easier coding
> solution may be to create a component that builds and executes a
> cfquery by taking a java style prepared statement. A rough idea:
>
> <cfcomponent>
> <set variables.dsn = "" />
> <cffunction name="init" ....>... init component and set datasource
> name</cffunction>
> <cffunction name="executePreparedStatement" returntype="query">
> <cfargument name="statement" type="string" hint="eg. select * from
> foo where bar = ?" />
> <cfargument name="params" type="array" hint="Array of structs with
> two keys, 'type' and 'value' />
>
> <cfset var theQuery = "" />
> <cfquery name="theQuery" datasource="#_dsn#">
>
> ...// code to parse the statement and insert cfqueryparams in
> place of the '?'s
> </cfquery>
>
> <cfreturn theQuery />
> </cffunction>
> </cfcompont>
>
>
> > What a hassle. This is worse than the fact that you can't use cfform
> > controls outside of a cfform tag in CFC cffunctions.
>
> I don't believe it makes sense for CF to be able to do what you are
> asking. Given a bare <cfqueryparam .../>, how is it to know what to do
> with it?
>
> Dominic
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321713
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4