Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cfscript implementation convert query to structs array. created in railo
/**
* Converts a coldfusion query into a coldfusion struct
*
* @param required query source query to convert
* @return struct converted query as a array with structs
*/
array function toStruct( required query source) output="true" {
var arrResult = arraynew(1);
var cols = ListtoArray(arguments.source.columnlist);
var row = 1;
var thisRow = "";
var col = 1;
for(row = 1; row LTE arguments.source.recordcount; row = row + 1){
thisRow = structnew();
for(col = 1; col LTE arraylen(cols); col = col + 1){
thisRow[cols[col]] = arguments.source[cols[col]][row];
}
arrayAppend( arrResult, duplicate( thisRow ) );
}
return(arrResult);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.