Jump to content

Read, Modify, Write in one operation


Hodo

Recommended Posts

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

  • 2 weeks later...

*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 :o

 

Sort of ;-) Obviously, IDs never change; and for certain counters, you need to make sure the number is up-to-date across all threads.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.