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()
?
StructKeyExists()Determines whether a specific key is present in a structure. StructKeyExists( struct=struct, key=string ); Returns: Boolean. Argument.
Cystic fibrosis (CF) is an inherited disorder that causes severe damage to the lungs, digestive system and other organs in the body. Cystic fibrosis affects the cells that produce mucus, sweat and digestive juices. These secreted fluids are normally thin and slippery.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With