Lets imagine a bug tracking application which has a bunch of projects in it - each project has a bunch of toggle-able settinsg such as "allow_anonymous_viewing" and "supports_cost_accounting"
Now this application has a user interface that lets the user quickly toggle these settings one at a time OR to go in and fully edit the project. When the user goes to fully edit the project then sure the whole record needs to be written to the database
but, when toggling just one value at a time why would you want to read the entire project data down, change one setting, then update the entire project record again when the process could have just involved updating that one setting where projectID=x?
sure, the same app might have the project information cached in the users session; but it might not (for who knows what reason). Should the application have to make the extra trip to the database to populate some bean just to update a single column in the record? I don't think so. I think it would be terribly inefficient.
Bill
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
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
--
[EMAIL PROTECTED]
http://blog.rawlinson.us
If you want Gmail - just ask.

