I use a nearly identical version of that for null strings and numbers.

I also use one for dates that uses our "magic" null date:

<cffunction name="IsNullDate" returntype="boolean" output="false">
        <cfargument name="dt" type="string" required="true" />
        <cfreturn (arguments.dt is "" or arguments.dt is "1/1/1950")>
</cffunction>

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Peter J. Farrell
Sent: Thursday, July 14, 2005 11:05 AM
To: [email protected]
Subject: Re: [CFCDev] Handling NULL's in a DAO

Trevor Orr wrote:

>I wrote this function for handling NULLs.
>
><cfqueryparam cfsqltype="cf_sql_integer"
>value="#arguments.CustomerBean.getGuarantor()#"
>null="#IsNull(arguments.CustomerBean.getGuarantor())#" /> 
>
>
><CFFUNCTION NAME="IsNull" returntype="boolean" OUTPUT="false">
>       <CFARGUMENT NAME="Value" TYPE="String" REQUIRED="TRUE">
>       
>       <CFSET var IsNull = FALSE>
>       
>       <CFIF Trim(Arguments.Value) EQ "">
>               <CFSET IsNull = TRUE>
>       </CFIF>
>       
>       <CFRETURN IsNull>       
></CFFUNCTION>
>  
>
This function should run faster as the number of sets has been reduced 
to 0, CF doesn't have to make a comparison with EQ, no conditional 
statement and the code goes from six lines to one line.

<cffunction name="isNull" access="public" returntype="boolean"
output="false">
        <cfargument name="value" type="string" required="true" />
        <cfreturn NOT len(arguments.value)>
</cffunction>

Considering the what is in the function - I think that #NOT 
len(arguments.someBean.getSomeVar)# would be faster as you don't have to 
make a function call.   I usually prefer to make sure all my data is 
good (validated and trimmed etc) before my DAOs - so I left out a trim() 
in the function

Best,
.Peter

-- 
Peter J. Farrell :: Maestro Publishing

blog    :: http://blog.maestropublishing.com
email   :: [EMAIL PROTECTED]

Create boilerplate beans!
Check out the Mach-II Bean Creator - free download.
http://blog.maestropublishing.com/mach-ii_beaner.htm



----------------------------------------------------------
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).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]







----------------------------------------------------------
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).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to