Hi There,

I tend to use structs (although arrays are also good) for passing
information in and out of methods as it allows you to pass status
information as well as queries and anything else you might want. It also
allows different methods to support the same interface without actually
returning the same data - just the same broad data type. 

For instance, when you call a method in your business façade or model
service layer to return data for the screen (anything from an addtoCart() to
a viewPage()) they may contain different combinations of queries and objects
which their associated views will know how to handle, but if you're type
checking, you need to return an array or struct so all of them implement the
same effective interface.

Just be aware of how ColdFusion handles arrays in terms of by reference vs.
by value passing. Here is a good thread on it:
http://www.compoundtheory.com/?action=displayPost&ID=65

Equally be aware that structs are always passed by reference so to keep
encapsulation you may want to use Duplicate() when passing it between
components.

Just wanted to mention this as I got caught out when I first started passing
structures around and found that changes to my local "copies" of structures
were actually changing the master structure because I hadn't used duplicate.

Best Wishes,
Peter


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Joseph Lamoree
Sent: Friday, July 07, 2006 10:21 PM
To: [email protected]
Subject: Re: [CFCDev] Stupid Question


On 3 Jul 2006, at 18:26, Ryan Everhart wrote:

> I am working on a CFC where I need to return 2 queries from a
> stored proc to the page.  Is it possbile to return two query sets  
> from a CFC function?

If you really need to get both queries back in a single return, you  
could create an array to contain both:

<cfset result = arrayNew(1)/>
<cfset arrayAppend(result, queryOne)/>
<cfset arrayAppend(result, queryTwo)/>
<cfreturn result/>

You probably don't intend to make updates to the data inside the  
array, so it won't matter if the result is returned by reference or  
by value.

--
Joseph Lamoree


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).

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





----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

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


Reply via email to