Re: Data integrity checking w/ PHP & MySQL?

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: Data integrity checking w/ PHP & MySQL?
References: 1  Groups: php.db php.general 
Request: Send a blank email to php-general+get-29145@lists.php.net to get a copy of this message
I think that you are probably running into the challenge of working without transactions. I suspect that you may be retreiving the current number of votes from the database, incrementing it in the PHP code, and then replacing the current value in the database with the new value. A better way, as suggested in the MySQL manual, would be to increment the value directly in the database, and then you won't have issues of out-of-date values trampling newer values. An example of the database increment would be 'UPDATE tbl_name SET votes=votes+1 WHERE pic_id=5' I think that this may help you with your problems. Thanks. Peter On Thu, 7 Dec 2000, Chad Day wrote: > I've run into some problems on my high traffic site, bangable.com, with what > appears to be data integrity in MySQL, and was wondering if there are any > checks I can do in PHP to validate that the right information was updated. > > I have a ton of inserts/selects going on.. in little over a day the number > of queries has reached 1 million. This is an amihotornot type site, what > happens is the user votes on a picture, that rating/# of votes is updated in > the DB, the persons IP thrown into a database, then moves onto the next > picture.. I've gotten a few reports of people who have had like 600 votes > then all of a sudden they drop to like 27 (or some other random #) or their > score changes, or some combination of the 2. I've only had about half a > dozen reported cases of this, and half a dozen in several million queries is > pretty good, but it reflects badly on the integrity of the system and I need > to correct that. > > Is there any way I can code in a check in PHP to see if it got updated > correctly without inducing too much overhead? While searching around the > net this morning for data integrity in MySQL, what I basically saw was the > check needs to be coded in the programming language. If anyone has > recommendations on how to do this, I would appreciate it. I don't want to > switch over to another DB unless there's no solution, as I didn't use a db > wrapper and changing all those database calls would really suck. > > Thanks, > Chad Day >

« previous php.general (#29145) next »