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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<cfquery> and <cfinclude> Any lurking danger?

Status
Not open for further replies.

josel

Programmer
Joined
Oct 16, 2001
Messages
716
Location
US
Suppose <cfmlA.cfm> includes <cfmlB.cfm> within which I define <cfquery name=&quot;ABC&quot; ...>; can <cfmlA.cfm> make reference of &quot;ABC&quot; query further down or even within <cfmlB.cfm> which is included further down?

I guess I am trying to wonder if CF resolves each template individually or if they are all loaded and then interpreted. If it works under the second scenario, then I guess I should be able to ...

I ran into a problem where formA was calling actionA and actionA includeded includeA. While actionA was able to identify url.variable, includeA was not.

Any comment on the logic and/or rules about this practice will be appreciated.

Thank you all in advance;


josel If you have the knowledge, consult and educate those who need it! - Jose Lerebours
 
Yes, you can reference a query in template b after it is included.

This may sound obvious, but if you conditionally include it, say inside a cfif tag, then it would not be availalbe.

e.g
<cfif myVar is &quot;true&quot;>
<cfinclude template=&quot;templateb.cfm&quot;>
</cfif>

If myVar was false, then templateb.cfm would not be processed, and if the query was in that file, then you would get an error.

HTH,
Tim P.
 
Hey Dude, thank you for such quick response.

I think I understand what you mean by the potential error if query is ONLY executed under certain condition. I guess that one would have to make reference of said query under the same condition thus making sure that that query was loaded/executed (or you can set variable and check variable prior to ...).

Thank you!

josel

If you have the knowledge, consult and educate those who need it! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top