Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at Scotch On The Rock (SOTR) 2010 (Brussels) with:

ColdFusion Query Argument Reference Can Be Confusing

By Ben Nadel on
Tags: ColdFusion

I was experimenting with a QueryAppend() function when I came across an interesting caveat to query variables. In ColdFusion, queries are passed around by reference. That is, if you pass a query to a method, such as QueryAddRow(), no query is returned because the original query object is updated by reference; however, this does not always seem to be the case. In my experimentation, I found that QueryAddRow() did in fact update the original query:

  • <cfset QueryAddRow( ARGUMENTS.QueryOne ) />

... but, changing the pointer of the query did NOT change the original reference:

  • <cfset ARGUMENTS.QueryOne = 3 />

This one leaves the original query alone and only affects the local variable, ARGUMENTS.QueryOne. I am sure this has to due with when the variable value is dereferenced or evaluated, but it seems to be a bit confusing.



Reader Comments

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.