> Here's a simple cfc function:
> <!--- List users method --->
>    <CFFUNCTION NAME="List"
>                RETURNTYPE="query"
>                HINT="Get complete user list">
>
>       <!--- Get users --->
>       <CFQUERY NAME="users" DATASOURCE="exampleapps">
>       SELECT EmployeeID AS UserID, FirstName, LastName
>       FROM tblEmployees
>       ORDER BY LastName, FirstName
>       </CFQUERY>
>
>       <CFRETURN users>
>    </CFFUNCTION>
>
> Now, do you think "CFRETURN users" is the equivalent of
> <cfset users = Duplicate(users)> or <cfset users =
> StructCopy(users)> another OR probably is not very likely.
>
> Though in most cases, I believe both would return same
> resultsets.

Within CF, whenever you pass a recordset or a structure, they are passed by
reference unless you explicitly use Duplicate or StructCopy. It doesn't
matter whether you're passing within a CFSET tag, or with the return value
of a function.

However, in the case you provide, it probably doesn't matter very much,
since you're not using the query "users" again within the function. You
should, however, ensure that you declare and initialize any variables you
use within a function as local variables.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
phone: 202-797-5496
fax: 202-797-5444
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to