|
That's a little obscure. You're var scoping that variable by simply
setting it to an empty string before you effectively reassign it as the
query name in the cfquery tag. You could also do <cfset var coreLV =
queryNew(columnlist [, columntypelist])
>, but it's easier to just let ColdFusion dynamically reassign it. It's important particularly to var scope variables like this so they don't wind up in the variables scope of the CFC and possibly cause unintended consequences. Sometimes it doesn't make any difference, but when it does, it's very difficult to debug, because the problem is quite hidden. So it's better to make sure you always var scope local variables. It's kinda similar to how you can affect a .cfm template where you have a local variable set on the page. Something like: <cfset myName = "Joe" > If someone messes with the query string in the url and adds &myName=Tommy to the end, myName changes, and that can mess things up. If instead, you place myName in the request scope : <cfset request.myName = "Joe" > it can't be unintentionally affected by url or form scopes. var scoping your local variables in your functions follows the same principle. It ensures the function is encapsulated so that any variable assignments that happen within it do not affect anything else (and perhaps visa versa). Once you get into more heavy duty CFC use, serious problems can arise from neglecting this small detail. :) Nando Hamoud, Ryan N. wrote:
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected] |
- [CFCDev] New IE broswer "Activate ActiveX Contr... Ung, Seng
- Re: [CFCDev] New IE broswer "Activate Activ... Daniel Roberts
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- Re: [CFCDev] cfc scope issues Daniel Roberts
- Re: [CFCDev] cfc scope issues Matt Woodward
- Re: [CFCDev] cfc scope issues Nando
- RE: [CFCDev] cfc scope issues Phillip Senn
- Re: [CFCDev] cfc scope issues Patrick Lebon
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- Re: [CFCDev] cfc scope issues Nando
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- RE: [CFCDev] cfc scope issues Jean Moniatte
- Re: [CFCDev] cfc scope issues Peter J. Farrell
- RE: [CFCDev] cfc scope issues Phillip Senn
- Re: [CFCDev] cfc scope issues Matt Woodward
- [CFCDev] cfc scope issues Nando
