See inline comments on code changes.

On Fri, 10 Sep 2004 15:05:43 -0400, Dwyer, Sarah <[EMAIL PROTECTED]> wrote:
> <cffunction name="select_query" hint="This function handles all select
> queries and through different attributes will process queries differently."
> output="true" returntype="query">
> 
> <cfargument name="sql" required="true" type="string" hint="The sql query to
> run."/><cfargument name="datasource" required="false" type="string"
> default="xyz" hint="The datasource to run the query against."/>
> <cfargument name="cached" required="false" type="string" default="no"
> hint="This specifies that the query should be cached."/>
> <cfargument name="cacheTime" required="false" type="string" hint="This
> specifies how long a query should be cached, only used if cached=1."/>
> 
> <cfargument name="requery" required="false" type="string" default="no"
> hint="This specifies that this query is a query of a query."/>

You need to add:
    <cfset var subquery = 0 />
    <cfset var tS = 0 />
here and remove the 'var' from the two <cfset> lines below - 'var' can
only be used at the beginning of a function so all 'var' declarations
must appear first.

>                 <!--- handle caching time --->
>                 <cfif arguments.cached EQ 1>
>                         <cfset var tS = arguments.cacheTime>

Remove var from the above line.

>                 <cfelse>
>                         <!--- put in zero to force no caching --->
>                         <cfset var tS = createTimeSpan(0,0,0,0)>

Remove var from the above line.

>                 </cfif>
>                 <cfif arguments.requery EQ "yes">
>                         <!--- do a query of a query --->
>                         <cfquery name="this.subquery" dbtype="query"
> cachedwithin="#tS#">

Don't use "this" scope. Change that line to:
              <cfquery name="subquery" dbtype="query" cachedwithin="#tS#">
i.e., use the local subquery variable declared above.

>                                 #preserveSingleQuotes(arguments.sql)#
>                         </cfquery>
> 
>                 <cfelse>
>                         <!--- query the database directly --->
>                         <cfquery name="this.subquery"
> datasource="#datasource#" cachedwithin="#tS#">

Same comment as above. Change this.subquery to just subquery.

>                                 #preserveSingleQuotes(arguments.sql)#
>                         </cfquery>
>                 </cfif>
>                 <cfreturn this.subquery>

Change this.subquery to just subquery.

>         </cffunction>
-- 
Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to