Skip to content

Instantly share code, notes, and snippets.

@noedlm
Last active November 9, 2017 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noedlm/b25d8503b7700ad3f9720645d7f03807 to your computer and use it in GitHub Desktop.
Save noedlm/b25d8503b7700ad3f9720645d7f03807 to your computer and use it in GitHub Desktop.
Coldfusion: Perks of iterating through structures and arrays using .each()
json = getPayload();
courses = deserializeJson(json); //this returns an array of structs
for(course in courses) {
importClass(course);
}
function importClass(required struct course) {
queryObject = new query(datasource);
queryObject.addParam(name="fieldA", value=arguments.course["fieldA"]);
queryObject.addParam(name="fieldB", value=arguments.course["fieldB"]);
queryObject.addParam(name="fieldC", value=arguments.course["fieldC"]);
//build and execute insert/update query
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment