How to access a region if its name is used as a query column

Turning to some outdated code, we were faced with a rather annoying situation. We iterate over the query with the tag <cfoutput query="x">. This query has a column named 'url'. Inside this loop, we need to check if the key exists in the URL area. Since CF puts priority on what in the query on common page areas, I can’t use structKeyExists(url,"key"), since CF refers to url in this question, this is a string with the value from the current query string.

How can I go out of the request area and check what is in my URL?

We use isDefined ("url.key") as a temporary one, but I would still like to know if there is a way to get out of the request area.

It is also impossible to change the column or even the column name in the query without several hours of work, tracking the change of all links to it, so we will avoid this, if at all possible.

EDIT : There seems to be some confusion as to how this code is configured, and why simple solutions don't apply. It would be hard for me to give a detailed example, but I will try to clarify the situation.

There are many pages that will be considered "pageA" for the following example. It is enough that a change in how this works requires a change in volume and investment over time, which simply will not occur within the allotted time.

url, cfoutput, BB. URL, , , - (varID = x vid = x ). PageB url, ( "varID" URL-, , "vid" ).

"" , url, url . , -, .

, , , , , . , URL , url , .

+3
5

, , , url, ( ) url :

<cffunction name="getUrlScope"><cfreturn Url /></cffunction>
...
<cfoutput query="x">
<cfif StructKeyExists( getUrlScope() , 'key' )>
    <!--- still fails :( --->


( ) . getPageContext(), , , .

getPageContext().SymTab_findBuiltinScope('URL') URL.

getPageContext().getCfScopes() . , , , , [cgi,?, Url, form, cookie,?] CF10, cflive (CF9), , .

( CF8 getBuiltinScopes, - , .)

Railo , getPageContext.UrlScope() .

+3

url struct cfoutput, url. :

<cfset urlScope = url>

<cfoutput query="x">
  <cfset keyExists = structKeyExists(urlScope, "key")>
</cfoutput>
+3

url int

SELECT URL as qURL FROM myTable ...

( elswhere ..), , .

URL- , . , (.. URL FORM) , (.. ).

+1

Could you move structKeyExists (url, "key") outside the cfoutput block and store this in a variable? Or do structAppend to copy the url structure to another structure named something else?

0
source

Another approach is to replace the cfoutput block with the cfloop block.

<cfloop from="1' to = "#YourQuery.recordcount#" index = "idx">
<cfif StructKeyExits(url,"key")>
<cfoutput>
#url.key# is not the same as #YourQuery.url[idx]#
which can also be referenced like this #YourQuery["url"][idx]
etc
0
source

All Articles