Convert struct to query
Copy link to clipboard
Copied
Hi there
Wondering if anyone can assist
I am utilizing some code from ria.forge which integrates with the last.fm api...
One of the methods outputs as a struct, but I would like to modify the code so it outputs as an array, am unsure of how to do this..
Currently the code is like this
<cfscript>
var args = StructNew();
var returnStruct = StructNew();
var results = "";
var i = 0;
args['playlistURL'] = arguments.playlistURL;
results = super.callMethod('playlist.fetch', args).playlist;
returnStruct['title'] = results[':title'];
returnStruct['annotation'] = results[':annotation'];
returnStruct['creator'] = results[':creator'];
returnStruct['date'] = results[':date'];
if(StructKeyExists(results, ':trackList') AND StructKeyExists(results[':trackList'], ':track')){
results = super.ensureArray(results[':trackList'][':track']);
returnStruct['tracks'] = QueryNew('album,creator,duration,identifier,image,info,title');
for(i=1; i LTE ArrayLen(results); i=i+1){
QueryAddRow(returnStruct.tracks);
QuerySetCell(returnStruct.tracks, 'album', results.album);
QuerySetCell(returnStruct.tracks, 'creator', results.creator);
QuerySetCell(returnStruct.tracks, 'duration', results.duration);
QuerySetCell(returnStruct.tracks, 'identifier', results.identifier);
QuerySetCell(returnStruct.tracks, 'image', results.image);
QuerySetCell(returnStruct.tracks, 'info', results.info);
QuerySetCell(returnStruct.tracks, 'title', results.title);
}
}
return returnStruct;
</cfscript>
Am just wondering if there is a coldfusion method that allows me to convert the returnStruct into a query..
Many thanks

Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi
Iv looked at this before, isnt this more converting a query to a struct?
Thanks

