I like to use an 'iterating business object', or IBO. At its most basic, the component has the cfquery object as a property, as well as a pointer to the current row. It has methods for looping the query, ie. next(), previous(), first(), last(), etc. These I put in a base IBO component. It also has business logic methods that apply to the current row, and these I put in the individual IBOs that extend the base.
The IBO takes a Data Access Object (DAO) as an argument in it's constructor and I standardize my DAO methods so this can be done generically (but can be tweaked if neccessary). It is basically bean and gateway in one - without all the wasteage. An example useage might look like: myTableIbo.load( myPkId ); // here the ibo would call its DAO's load method and set the resultant query as its query property, ready to be iterated <!--- an example output using the BL method getSomeColumn() ---> <cfloop condition="myTableIbo.next()"> #myTableIbo.getSomeColumn()# </cfloop> I actually prefer to just use plain queries in my display pages and have a getQuery() method in the IBO for releasing the query for display - but using the IBO in the display page doesn't bother me either. Dominic 2009/3/25 Donnie Carvajal <donnie.carva...@transformyx.com>: > > I have been trying to write my applications using the 3 tiered method of > development, presentation layer, business logic layer and data access layer. > I am having trouble coming up with an efficient method of displaying > information returned in a query that has multiple records. Correct me if I'm > wrong, but shouldn't all data be placed into an object based on a component > so that the business logic can massage the data and return valid inforamtion > based on business rules. If I am correct that that means that I should > create an object for every record of the query before I display the data. > Doing this slows down my web pages by 100-200% going from fractions of a > second to around 20 seconds for a query that returns 100 records. All of the > examples that I have come across on the web run the query in the data > application layer and then in the presentation layer, loop over the query and > output the data straight from the query (i.e. #qEmployees.firstName#). The > problem I have with outputting the data straight from the query is that I > will have to have business logic in 2 places. In the business logic > component and the data access component. > > How are you (anyone who would like to reply) handling this scenario and > keeping the integrity of the business logic? > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320960 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4