On 9/19/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I like that idea, but how do you handle data that already exists in your > database? So, you are using your setter to establish the instance data, > correct? The data that comes from your database is sent through your > setter when you are establishing your instance data?
I can't remember the last time I needed to explicitly set a field to NULL. I guess with a combination of refactoring and use of default values I tend to wiggle my way out of it. :) I like Bill's answer. > on saving my DAO also knows the magic number and so the > cfqueryparam will save a null if the value= the magic number: > > <cfqueryparam cfsqltype="cf_sql_integer" value="#x.getY()#" > null="#x.getY() EQ magicNumber#" /> Though you might want to do an Extract Method on that code. <cfqueryparam cfsqltype="cf_sql_integer" value="#x.getY()#" null="#x.isYNull()#" /> <cffunction name="isYNull" returnType="boolean"> <cfreturn getY() EQ variables.magicNumber/> </cffunction> Now the magic number is hidden inside the object, so you can change it without affecting any other code. In fact, there doesn't even need to be a magic number. You could use a flag instead. Patrick -- Patrick McElhaney 704.560.9117 http://pmcelhaney.weblogs.us ---------------------------------------------------------- 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]
