Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.