Iterates over query rows and passes each row per iteration to a callback function
queryEach(query, function(row [, currentRow] [, query] ){} [, parallel] [, maxThreads])
→ returns void
query.each(function(row [, currentRow] [, query] ){} [, parallel] [, maxThreads])
row
*
struct
:
A struct with all of the columns for the current iteration
currentRow
*
numeric
:
The value for the current iteration
query
*
query
:
A reference of the original struct
20
parallel
argument is set to false it will be ignored
ACF 2016+ and Lucee 5+
<cfscript>
news = queryNew("id,title",
"integer,varchar", [{
"id": 1,
"title": "Dewey defeats Truman"
}, {
"id": 2,
"title": "Man walks on Moon"
}]
);
function newsRow(row) {
writeOutput("<tr>");
writeOutput("<td>#row.id#</td>");
writeOutput("<td>#row.title#</td>");
writeOutput("</tr>");
}
</cfscript>
<table>
<cfscript>
queryEach(news,newsRow);
</cfscript>
</table>
Expected Result: 1 Dewey defeats Truman 2 Man walks on Moon
Lucee 5+
<cfscript>
news = queryNew("id,title",
"integer,varchar", [{
"id": 1,
"title": "Dewey defeats Truman"
}, {
"id": 2,
"title": "Man walks on Moon"
}]
);
function newsRow(row) {
writeOutput("<tr>");
writeOutput("<td>#row.id#</td>");
writeOutput("<td>#row.title#</td>");
writeOutput("</tr>");
}
</cfscript>
<table>
<cfoutput>#queryEach(news,newsRow)#</cfoutput>
</table>
Expected Result: 1 Dewey defeats Truman 2 Man walks on Moon
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.