On top of some of the 'big ticket' items in ColdFusion 10, there are also a lot of small langauge enhancements that will make it even easier to use ColdFusion. One such example is using for-in syntax in queries.
Here is a basic example:
2 books = new query(datasource="cfbookclub", sql="select * from Books").execute();
3 for( book in books.getResult() ){
4 writeOutput( "<strong>Title:</strong> " & book.title);
5 writeOutput(" <strong>Description:</strong> " & book.bookdescription & "<hr/>");
6 }
7 writeDump( book )
8</cfscript>
Here is the result of the dump from the code above.

Notice that, for each iteration, the value of book (or whatever your variable is named) is a structure where each of the keys is a column name from our query. This actually makes a lot of sense since a ColdFusion query object is nothing more than a specialized array of structures anyway.
As well as some of the bigger additions, I plan on blogging more about language enhancements such as this as they can get easily overlooked.




3 comments