queryEach

Interates over query rows and passes each row per interation to a callback function

queryEach(query, closure [, parallel] [, maxThreads]) → returns void

Member Function Syntax

query.each(closure [, parallel] [, maxThreads])

queryEach Argument Reference

query query
Required

closure function
Required

parallel boolean

Lucee 4.5+ Executes closures parallel

maxThreads numeric
Default: 20

Lucee 4.5+ Maximum number of threads executed
If "parallel" argument is set to false it will be ignored

Compatibility

Lucee:

When called as a member function query.each() is chainable.

Links more information about queryEach

Examples sample code invoking the queryEach function

<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>
<cfoutput>
    <table>
        #queryEach(news,newsRow)#
    </table>
</cfoutput>

Expected Result: 1&emsp;Dewey defeats Truman 2&emsp;Man walks on Moon


Fork me on GitHub