Using StructKeyExists in place of IsDefined
coldfusion, struct
Solution
The default scope is variables, so `StructKeyExists(variables,"getname")` will perform your check for you.
However, unless there's missing logic in the example above, you don't need the isDefined/StructKeyExists check, because if you run a query, it'll always be defined, just with no rows present, so your second check on `getname.recordcount` should be sufficient.
Problem
For code enhancement purposes, we are going to convert all `isDefined()` calls to `structKeyExists()`. A couple of things that I need to know are: How do we define a query in `structKeyExists()`? For instance: ``` <cfquery name="getname" datasource="dsn">select * from table</cfquery> <cfif isDefined('getname') and getname.recordcount neq "">Do this</cfif> ``` Since there is no scope defined for `isDefined()`, what scope should we use for `structkeyExists()`?