" However, if the CFC stores things in session scope - why bother returning 
them at all? Why not just let the caller access session.stuff directly?"

---------------------------

>From the display perspective I won't know the scope in which to look for the
data...instead I use a combination of  get/set methods to create and access
these objects....

For the display I have:

<cfinvoke 
 component="report.facade"
 method="getSummary"
 returnvariable="aStruct">
</cfinvoke>

<cfloop query="aStruct.query1">

</cfloop>

For certain roles that data will reside in application scope and others in
session....I felt I needed to do this because the app is very data
intensive. 

Stace

-----Original Message-----
From: Sean A Corfield [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, August 03, 2002 6:17 PM
To: CF-Talk
Subject: Re: cfreturn session.records ?

On Saturday, August 3, 2002, at 02:58 , Stacy Young wrote:
> If I have a CFC that stores its results in session scope is the data
> duplicated on the return or is the session data just referenced via 
> pointer
> of sorts?

It uses reference semantics. However, it's not really good practice to 
have CFCs store results in shared scopes - CFCs should be independent of 
their environment.

However, if the CFC stores things in session scope - why bother returning 
them at all? Why not just let the caller access session.stuff directly?

>   <cffunction name="getAccounts">

You should add returntype="query" for extra validation.

>             <cfquery name="session.test">
>             SELECT * FROM BLAH
>              </cfquery>
>             <cfreturn session.test>
>    </cffunction>

You'd be better off having the caller (only) know about the session scope 
and using a local variable inside the function:

        <cfset var test = 0/>
        <cfquery name="test">
                SELECT * FROM BLAH
        </cfquery>
        <cfreturn test/>

Then the caller would do:

        <cfinvoke component="accounts"
                method="getAccounts"
                returnvariable="session.aQuery"/>

if you wanted it to stay in session scope (the query is not copied, only a 
reference to it, so this is fast). Or, if you just wanted a local copy:

        <cfinvoke component="accounts"
                method="getAccounts"
                returnvariable="aQuery"/>

Note that since 'test' inside the function is declared with 'var', it will 
be a new copy for every invocation.

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood


______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to