Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created May 20, 2013 13:53
Show Gist options
  • Save bennadel/5612364 to your computer and use it in GitHub Desktop.
Save bennadel/5612364 to your computer and use it in GitHub Desktop.
Using A Dynamic Column Name With ValueList() In ColdFusion
<cfscript>
friends = queryNew( "" );
// Add our name column with initial row values.
queryAddColumn(
friends,
"name",
"cf_sql_varchar",
[ "Sarah", "Tricia", "Jill" ]
);
// Create a variable that holds our "dynamic" column reference.
targetColumn = "name";
// Use the evaluate() function to invoke the valueList() function
// using our dynamic column reference.
writeDump(
evaluate( "valueList( friends.#targetColumn# )" )
);
</cfscript>
valueList( users.id );
valueList( users[ "id" ] );
column = users[ "id" ];
valueList( column );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment