I'm building a highway noise barrier inventory tool that will allow people to search all the current highway noise barriers in the US by state, type, material, etc (I know, I know, exciting stuff).
I'm needing to slice and dice the data many different ways, so I'm using cffunctions and cfcs. I've found out that it works better to have a function for each thing I want to call, rather than trying to stuff it all into a two or three huge queries. This has worked well, except for one place, where I have a list of barriers by state and year, and within each record, I have to grab all the materials. This is sort of a query in a nested loop, and as such, is SLOW.
I solved the speed problem on another page by just running one bit cached query at the top of the page, then doing this:
<cfset qgetMaterialsbyID = structNew()><cfloop query="qgetallbarriermat"> <cfset qgetMaterialsbyID[qgetallbarriermat.barrierid[qgetallbarriermat.currentRow]] = qgetallbarriermat.material[qgetallbarriermat.currentRow]></cfloop>
This has worked great (and has been super fast) when I want to get one piece of information, but in this case, I can have multiple materials per barrier.
qgetMaterialsbyID[id].material works great for getting one of the materials, and I can dump qgetMaterialsbyID[id] to get them all, but I can't figure out how to loop through qgetMaterialsbyID[id] to get all the materials for that ID. Or maybe that struct is only good for one result? I've been staring at it for so long, I'm not sure which way is up anymore. Thanks for any help!