Simon Baynes: Web Development

Undocumented Query Methods

As a die hard cfscript fan I often find myself frustrated that I cannot use all of ColdFusion's functionality from within a cfscript block. Happily www.cflib.org has several functions that let you get around these.

There are also some very helpful undocumented Java methods that you can use with queries in ColdFusion.

<cfscript>
    // get your query from a function
    qGetMyQuery = myFunction();

    // this method sets the query's position to zero. ie before the first member
    qGetMyQuery.beforeFirst();

   // now we are going to use a while loop to go loop through the query
   while (qGetMyQuery.next()) {

       writeOutput(qGetMyQuery.columnName[qGetMyQuery.currentRow] & "<br />");
   }
</cfscript>

Please bear in mind that these are undocumented techniques and so should be tested if used when you upgrade ColdFusion.

By Simon Baynes