Link to home
Start Free TrialLog in
Avatar of jturkington
jturkington

asked on

CFLOOP Query & CFOUTPUT Query

When should you use CFLOOP Query and CFOUTPUT Query ??

Cheers

JT

Avatar of mmc98dl1
mmc98dl1
Flag of Australia image

Its dependant on the way the page is built.

In CFMX6 and up there is practically no difference in performance.

Alot of people like to put a cfoutput around the entire page and then do cfloops over the queries so you dont jump in and out of outputs. This keeps the page tidier, and if its a hug page, with lots of moving between cfoutput then I expect it will slow it down.

with cfloop you cant group by a value in the query, like you can with cfoutput.

Avatar of jturkington
jturkington

ASKER

Define a huge page ?

I use cfoutputs around each variable needed ?!?

Say for a page that has about 30 variables in it ?

Should i use just the one cfoutput ??

I would say that best practice - you should be using as few cfoutputs as possible.

If you are simply printing out a variable, and doing that 5 times in a row with some HTML in between, use one cfoutput around it all.  

If you have to output a query, use cfloop unless you need to do some funky grouping on it. This means you dont have to put cfoutput tags all over the place.
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial