Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFOUPUT - Best Practice 1

Status
Not open for further replies.

TamedTech

IS-IT--Management
May 3, 2005
998
GB
Hello Guys,

Just a small question on performance related best practices when it comes to outputting my query data.

I've seen several methods for using the CFOUPUT and was wondering which is the best practice.

Should I be defining my query in the 'query' attribute for the cfoutput tag? or am i better off defining my query in the actual output somthing like #queryname.fieldname# or should I be doing both?

If I'm not defining a query attribute then it leaves me to be able to ouput results from several query in a single cfoutput tag, should i be doing this? or am better off defining the ouput for each query in its own cfoutput tag?

Hope this makes Sense,

Rob
 
My thoughts..

<cfoutput query="myQuery"> #myQuery.fieldname#
ONLY when you are looping a query (more than one row)

<cfoutput> #myQuery.fieldname#
When working with single row queries

<cfoutput>
<cfloop query="myQuery">
#myQuery.fieldname#
In the rare occasion when I might have a ton of other output to do right before or after the query output.


Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Thanks for that Kevin, thats how I've been using at the moment, I just wanted to confirm that's what you other guys have been doing.

Thanks,

Rob
 
oh, and if there is nothing to display on screen, and I need to loop a query, I almost ALWAYS use cfloop, unless I need to use the group attribute of cfoutput

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Just one additional note ... it is always proper practise to define the scope of the variable when you output, so no matter which way you use the CFOUTPUT tag itself, you should always use #Queryname.Column# in your output.

You only need to use CFLOOP with Query if you will have other possible embedded queries, since an embedded CFQUERY loop would throw an error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top