Thought 1: Danger, Will Robinson!

Thought 2: Danger why?

Thought 3: Hmmmmmmmm...

Scenario: I have a preferences page with 2 checkboxes that represent bit columns in my database. I have a primary key (say userPrefsId) and 2 bit values (say... rememberMe and sendMeJunkmail). This is one page from my "Profile" section of the site. Why update a whole set of records when I have the ID and values and don't really need anything else or to update anything else.

Scenario: Change Password form. I have my AccountId and 2 password fields in my form. All I need to do is validate, hash() and save the password value. Why not just use the AccountId and password fields in the Account object? Why update a dozen columns when I only need to save 2?

Then it becomes possible to do something like this:

<cfset Account.save(arguments.event.getValue("fieldnames"))>

OK... so it looks viable at first blush. So what could go wrong? Well, obviously there's the matter of unsatisfied dependencies, which means that not only would save() need to be able to take a list of values to publish to the DB, but validate() would need to take that same list, I think. How else would you make sure that dependencies are satisfied before writing part of your record object to the DB?

Another thing that's nagging at me is the fact that a "record" is a whole. It's the smallest part of the data in the DB. Sure, there are component parts... think of a record as a molecule of data, comprised of protons, neutrons, defaults and foreign keys. So, is it really a GOOD idea to go around only saving pieces of this record to the database at a time? Something's disconcerting about that. My "gut hunch" is saying that if you have an object that represents a row in the DB, the whole row should be written out at once because the whole row IS the smallest cohestive unit... the columns are components of that row, sure, but they have no meaning or value outside the context of a whole row taken at once... hence the concept of a record.

Hey, you asked for thoughts... you never said they had to be concise, or even make sense! ;)

Laterz!


------------------------------------------------

Jared C. Rypka-Hauer

Continuum Media Group LLC

http://www.web-relevant.com

Member, Team Macromedia - ColdFusion


"That which does not kill me makes me stranger." - Yonah Schmeidler


On Feb 9, 2006, at 10:02 AM, Doug Hughes wrote:

<delivery mode=”nicest way possible”>Argh!</delivery>

 

You know.  I more or less rudely shot you down.  But now that I’ve done that (and you politely took it) I’ve been thinking about ways to do this.

 

The load and delete methods take various arguments to indicate what to load or delete.  Why not something akin to that for saving?  IE:

 

<cfset myRecord.save(“list,of,fieldnames”) />

 

Something like that might save only the specified fields for that record?  Of course, if you have constraint issues it’ll throw an error.

 

That seems like it might be handy.  Thoughts?

 

Doug

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Chris Terrebonne
Sent: Thursday, February 09, 2006 10:55 AM
To: [email protected]
Subject: RE: Reactor For CF Update single value

 

Doug,

 

Thanks for the great code and quick response.  I appreciate both. 

 

I’ll simply add the methods I need.  If it appears to be useful and reusable, I’ll forward you the changes.

 

Thanks,

Chris

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Doug Hughes
Sent: Thursday, February 09, 2006 9:35 AM
To: [email protected]
Subject: RE: Reactor For CF Update single value

 

Nope – There’s no way built in to do this (unless you have a two column table). 

 

I can’t make reactor everything to everyone.  You’re welcome to add your own methods to do what you need, as you need it.

 

Doug

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Chris Terrebonne
Sent: Thursday, February 09, 2006 9:48 AM
To: [email protected]
Subject: Reactor For CF Update single value

 

After digging through the docs and DAO, I was unable to find a way to update a single value (rather than updating every value in the table) using Reactor.  Is there a built in way to handle this, or will I have to extend the DAO?

 

Thanks,

Chris


Reply via email to