Click here to get back home

updating only when data is different

 HomeNewsGroups | Search

comp.lang.php - PHP programming language discussions 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
updating only when data is different student4life 07-02-2009
Posted by student4life on July 2, 2009, 9:43 pm
Please log in for more thread options
Hello,

If I have self-submitting page that will have the data fields
refreshed/updated ONLY when the data are different between each
submission, could someone show me what the best way is to accomplish
this task? I was thinking using $_SESSION variable and compare the
stored value to that of the $_REQUEST variable and proceed with
database operations only when there is a difference. TIA

Posted by jeff on July 3, 2009, 1:34 am
Please log in for more thread options
student4life wrote:
show/hide quoted text

I have to ask, what does it matter? If the data is the same, what
would it matter if it were overwritten. It's no less trouble to select
and compare than to just update. MySQL has REPLACE.

I assume there is something else?

Jeff


could someone show me what the best way is to accomplish
show/hide quoted text

Posted by C. (http://symcbean.blogspot.c on July 3, 2009, 7:29 am
Please log in for more thread options
show/hide quoted text

So the form submits itself but between times the user might have
changed something.

If you use a session then YOU ARE UPDATING THE (session) DATA EVERY
TIME ANYWAY.

I think the your objective is decidedly dubious, and your proposed
solution is innappropriate as per above. Assuming that your objective
is valid, then you could acheive it by including the original values
in one or more hidden form fields. This does make possible CSRF issues
would could be avoided by adding additional checks, e.g.

<?php
$prev=3D$_REQUEST['prev'];
unset($_REQUEST['prev'];
$payload_chk=3Dsha1(var_export($_REQUEST,true) . "s3cr3t"));
if ($payload!=3D$prev) {
update_date($_REQUEST); // data has changed
}
show/hide quoted text
$payload_chk=3Dsha1(var_export($_REQUEST,true) . "s3cr3t"));
show/hide quoted text
....show rest of form

C.

Posted by Gordon Burditt on July 6, 2009, 5:42 pm
Please log in for more thread options
show/hide quoted text

The database is likely to avoid writes if the data hasn't changed.

show/hide quoted text

As I understand the way alternate session save handlers work, if
you've got a session, the session data will be saved at the end of
processing the page. No conditions. The value of anything in
$_REQUEST has nothing to do with it.


Posted by Jerry Stuckle on July 3, 2009, 8:44 am
Please log in for more thread options
student4life wrote:
show/hide quoted text

What's the purpose you are trying to achieve? And where do you want to
update the data? Screen? Database? Mars? (Forget the last one :-) ).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Similar ThreadsPosted
Updating the SQL key value March 28, 2007, 9:50 am
Updating cookies April 6, 2005, 8:20 pm
Updating Records January 14, 2006, 8:34 pm
Updating MySQL with PHP July 18, 2007, 12:00 am
No apxs when updating PHP April 24, 2008, 5:12 pm
Updating an image June 11, 2008, 10:25 am
Updating auto_increment fields ? August 30, 2004, 11:47 am
apxs problem when updating PHP September 26, 2004, 8:20 pm
Problem updating PHP Include? August 17, 2005, 12:44 am
mySql updating numbers September 19, 2005, 8:09 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy