Copy link to clipboard
Copied
This question was posted in response to the following article: http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec0a0e0-7fdf.htm...
Copy link to clipboard
Copied
The code example loops through a query that uses do-while() is a poor example. It should utilize while(). We want to check first if there is a result set. If there is, then read the record. Using while() would eliminate the use of if() statement prior do-while(). do-while() means we want to run the first loop, then check a condition whether or not to run the subsequent loop. while() means we want to check if the first and subsequent loop is true.
Copy link to clipboard
Copied
More than that, the example (showing a do-while to loop over a query) can be removed as of CF10 with its new support for for-in looping over a query (shown near the bottom of this page). As there are other examples of do-while loops offered above it, there's really no need even to replace it with something else.
Copy link to clipboard
Copied
For the last code, an opening angle bracket (<) is missing in the opening cfscript tag.