Revision: 58075
Updated Code
at June 23, 2012 15:47 by nuukem
Updated Code
<h3>From a Query</h3>
<cfquery name="settingsParameters" datasource="#dsn#">
SELECT NAME, VALUE
FROM MY_SETTINGS
WHERE ACTIVE = 1
AND SECTION = 'whatsNew'
</cfquery>
<!--- To output the results use one of these 2 mothods. The latter is the newer, simpler way to write it --->
<cfloop query="settingsParameters">
<cfset temp2 = SetVariable("settings.#settingsParameters.name#", settingsParameters.value) />
</cfloop>
<!--- OR, CF >= 8 (i think) --->
<cfloop query="settingsParameters">
<cfset "settings.#settingsParameters.name#" = settingsParameters.value >
</cfloop>
<h3>From a list</h3>
<cfset myList = "something=blah;what=now;who=jim">
<!--- Loop over list breaking it up on semicolon. create a temp array and use array[1] for the name of the variable and array[2] as the value i.e. bupid=7; creates <cfset additionalParams.bupid = 7> --->
<cfloop list="#myList#" delimiters=";" index="i">
<cfset k = listToArray(i,"=")>
<cfset "additionalParams.#k[1]#" = k[2] \>
</cfloop>
Revision: 58074
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 23, 2012 15:45 by nuukem
Initial Code
<h3>From a Query</h3>
<cfquery name="settingsParameters" datasource="#dsn#">
SELECT NAME, VALUE
FROM MY_SETTINGS
WHERE ACTIVE = 1
AND SECTION = 'whatsNew'
</cfquery>
<!--- To output the results use one of these 2 mothods. The latter is the newer, simpler way to write it --->
<cfloop query="settingsParameters">
<cfset temp2 = SetVariable("settings.#settingsParameters.name#", settingsParameters.value) />
</cfloop>
<!--- OR, CF >= 8 (i think) --->
<cfloop query="settingsParameters">
<cfset "settings.#settingsParameters.name#" = settingsParameters.value >
</cfloop>
<h3>From a list</h3>
<cfset myList = "something=blah;what=now;who=jim">
<!--- Loop over list breaking it up on semicolon. create a temp array and use array[1] for the name of the variable and
array[2] as the value i.e. bupid=7; creates <cfset additionalParams.bupid = 7> --->
<cfloop list="#myList#" delimiters=";" index="i">
<cfset k = listToArray(i,"=")>
<cfset "additionalParams.#k[1]#" = k[2] \>
</cfloop>
Initial URL
Initial Description
Create dynamic variables from a query or a list.
Initial Title
Creating Dynamic Variables
Initial Tags
Initial Language
ColdFusion