Hodo Posted July 2, 2007 Share Posted July 2, 2007 I want to change a value in a field. It is just a counter so I need to read the data add one then write it back or is there a simple way to do it? $query = "SELECT * FROM Tracks where id = '$id'"; if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_row($result)) { $row[1]++; <<< WILL SOMETHING LIKE THIS WORK? } } Link to comment https://forums.phpfreaks.com/topic/58068-read-modify-write-in-one-operation/ Share on other sites More sharing options...
Illusion Posted July 2, 2007 Share Posted July 2, 2007 Update tracks set id=id+1 where id='$id'; Link to comment https://forums.phpfreaks.com/topic/58068-read-modify-write-in-one-operation/#findComment-287936 Share on other sites More sharing options...
fenway Posted July 10, 2007 Share Posted July 10, 2007 *shudder* I'll pretend that you're not really trying to change the ID. And then I'll pretend that you don't care if it's thread-safe or not. Link to comment https://forums.phpfreaks.com/topic/58068-read-modify-write-in-one-operation/#findComment-294608 Share on other sites More sharing options...
Illusion Posted July 10, 2007 Share Posted July 10, 2007 *shudder* I'll pretend that you're not really trying to change the ID. And then I'll pretend that you don't care if it's thread-safe or not. is these words are pointing to me Link to comment https://forums.phpfreaks.com/topic/58068-read-modify-write-in-one-operation/#findComment-294697 Share on other sites More sharing options...
fenway Posted July 11, 2007 Share Posted July 11, 2007 *shudder* I'll pretend that you're not really trying to change the ID. And then I'll pretend that you don't care if it's thread-safe or not. is these words are pointing to me Sort of ;-) Obviously, IDs never change; and for certain counters, you need to make sure the number is up-to-date across all threads. Link to comment https://forums.phpfreaks.com/topic/58068-read-modify-write-in-one-operation/#findComment-295385 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.