Do you want to do this for a reason, or are you just trying to avoid 
unnecessary queries?

I can see this if you're stamping the records with a timestamp and/or 
noting the person who updated them, then you might want to avoid marking 
the record as updated when it actually wasn't.

But I'm not sure you gain much in the way of database activity, since 
you'll generally have to look up the record(s) after the page is 
submitted, then do comparisons, then conditionally do your updates.  Which 
is a lot of work to save what may not be much processing.  For 30 records 
it would require 30 select queries, plus your updates, which may save you 
little over just doing 30 updates and being done with it.

One technique to avoid the lookup queries on the server is to do 
everything on the client side using javascript, comparing data when the 
form is submitted, then turning on flags (sent as hidden fields) telling 
you whether you need to update a record.  This is also a lot of work, and 
is subject to the same caveats as relying soley on client side data 
validation.  In a controlled environment such as on an intranet, though, 
it may be acceptable.


----- Original Message ----- 
From: "Andy Mcshane" <[EMAIL PROTECTED]>
To: "CF-Talk" <[email protected]>
Sent: Friday, May 26, 2006 3:25 AM
Subject: Only update DB if data has changed?


> Hi all, does anybody have any ideas how I could best implement the 
> following;
>
> I have a page that loads anything up to about 30 individual records at a 
> time. Each record consists of 17 fields of data. All the records are 
> displayed on the page to give the user the option of editing any 
> individual field. When the user then submits the page I need to be able 
> to work out which records have had data changed and only do database 
> updates for those specific records. Having an individual submit for each 
> record is not an option, the whole page must be submitted as one but 
> only records that have changed should be updated. Can anybody suggest a 
> method for doing this?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:241549
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to