|
Posted by Jerry Stuckle on 05/21/06 16:39
Rik wrote:
> Jerry Stuckle wrote:
>
>>Sure you can guarantee it.
>>
>> $result = mysql_query("UPDATE myTable SET col1='$col1' AND
>> col2='$col2'] "WHERE col1='$oldcol1' AND
>> col2='$oldcol2'"); if (mysql_affected_rows != 1)
>> echo "Data has changed!<br>";
>>
>>If either col1 or col2 has been changed the update will fail and
>>mysql_affected_rows() will return zero.
>
>
> This doesn't guarantee it, I admit we're talking mili-, no, microseconds
> here. The problem is queries aren't instantanious, they take time.
>
> 2 Queries run:
> USER1 UPDATE WHERE is searched
> USER2 UPDATE WHERE is searched
> USER1 SETS
> USER2 SETS
>
> So, user 2 has overwritten changes made bu user 1.
>
> Likely no, possible yes.
>
> Grtz,
Actually, it does guarantee it.
During the update the row is locked so it can't be changed. This has been true
in MySQL for many releases.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|