queryClear

This function takes a query, removes all the rows, then returns a query object with no records

queryClear(query) → returns query

Member Function Syntax

query.clear()

This function requires Adobe ColdFusion 2018.0.5 and up.  Not supported on Lucee, etc.

Argument Reference

query query
Required

Compatibility

ColdFusion:

Version 2018.0.5+ New tag in Update 5

Examples
Sample code invoking the queryClear function

Description of the code example

heroes = queryNew("id,Name",
            "integer,varchar",
            [
                {"id":1,"Name":"Bruce Banner"},
                {"id":2,"Name":"Tony Stark"},
                {"id":3,"Name":"Bobby Drake"},
                {"id":4,"Name":"Jean Grey"}
            ]
            );
writeOutput("Query with records<br />");
writeDump(heroes);
writeOutput("The same query, but cleared<br />");
writeDump(heroes.clear());

Expected Result: A query with 4 heroes, then a query with none

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub