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.

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


Fork me on GitHub