You can circumvent this using duplicate( ) <cfset test = duplicate(test())/>
Which makes a deep copy of the object by value. -----Original Message----- From: Dave Watts [mailto:[email protected]] Sent: Tuesday, March 09, 2010 8:59 PM To: cf-talk Subject: Re: query passed by value from a udf? > Here's another useless question. When the following UDF is invoked, it > will return a query. Inside the UDF, the query is being assigned to > the local scope so theoretically it should 'die' when the UDF is > finished running. But it's returning a complex datatype, which should > be passed by reference. Is the query being returned passed by > reference or by value. I'm assuming value because the reference should > 'die' with the UDF. > > <cffunction name="test" returntype="any"> > <cfquery name="local.manga" datasource="mangadb"> > select top 1 * > from titles > </cfquery> > > <cfreturn manga> > </cffunction> Queries are always, ALWAYS, passed by reference, no matter what you're passing them into or out of. Let's assume you have a line below the function: <cfset myquery = test()> In this case, there are two references that point to the same object, assuming that you're calling the function and returning the value into a variable of your own. But there's only one object. The reference inside the function (local.manga) will go out of scope when the function exits, but the object corresponding to that reference will only go out of scope when the variable myquery itself goes out of scope. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:331512 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

