To be honest, I don't know if the existing vars are updated or destroyed.  
Either way, I don't expect the scope would change.  I just ran a quick test 
to see if the local scopes would change to the variables scope (which would 
be the only other scope I could imagine a variable automatically changing 
to without explicitly stating so).  The scope does not change.  Here's my 
test code:

<cffunction name="queryTest" returntype="void">
    <cfset var queryNewInit = QueryNew("")>
    <cfset var queryStringInit = "">
    <cfset var newDefined = false>
    <cfset var stringDefined = false>
    
    <cfset newDefined = IsDefined("variables.queryNewInit")>
    <cfset stringDefined = IsDefined("variables.queryStringInit")>
    
    <cfoutput>#newDefined# - #stringDefined#</cfoutput>
    
    <cfquery datasource="dsource" name="queryNewInit">
        select * from aTable
    </cfquery>
    
    <cfquery datasource="dsource" name="queryStringInit">
        select * from aTable
    </cfquery>
    
    <cfset newDefined = IsDefined("variables.queryNewInit")>
    <cfset stringDefined = IsDefined("variables.queryStringInit")>
    
    <cfoutput>#newDefined# - #stringDefined#</cfoutput>
</cffunction>

Both cfoutputs report "NO - NO".  This leads me to believe that the vars 
are staying in the local scope regardless of how it was initialized.


On Tuesday, June 24, 2014 5:46:57 PM UTC-4, Marcus F wrote:
>
> I haven't used QueryNew very often, but I'm going to, so I did some 
> playing around.
> Rawk, if you have input, I'd love to hear it.
>
> Here's an example of what I just did:
>     <cfset var theQuery = QueryNew("")>
>     <cfquery name="theQuery" datasource="wsem">
>         SELECT * FROM carts
>     </cfquery>
>
> Then I just used cfdump from the calling CFM file and it seems to work 
> just fine, the problem is that I'm not entirely sure about the scope, does 
> it change the existing var or destroy and recreate it, thus changing the 
> scope?
>
> On Tuesday, June 24, 2014 4:22:33 PM UTC-5, Jason Allen wrote:
>>
>> <cfset var redirectLookup = QueryNew()>
>>
>> I'm getting an error with that line of code. 
>>
>> It tells me I need arguments. 
>>
>> The query in the example is the following
>>
>>   SELECT redirectURL, redirectID, redirectStatus
>>       FROM tbl_redirects
>>       WHERE (redirectDomain = <cfqueryparam value="#arguments.domain#">) 
>> and (redirectSubFolder = <cfqueryparam value="#arguments.subFolder#">) 
>>
>>
>> So where I'm confused is whether or not an empty QueryNew() function 
>> should be enough. Or do I need to expand it aka queryNew('redirectURL, 
>> redirectID, redirectStatus', 'varchar, int, smallint')
>>
>> <cfset var redirectLookup = QueryNew()>
>>
>> <cfset var redirectLookup = QueryNew('redirectURL, redirectID, 
>> redirectStatus', 'varchar, int, smallint')>
>>
>>
>>

-- 
-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Open 
BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to