Hi Ron,

> My Scenario is if two users open an existing record with data already in
> the fields. They then add
> some information to the end of a field with data.
> Now when they click update the last user/browser gets written to the db,
> where the first users data is over written.
> 
> I thought innodb would help this..
> 
> 
> user a:                             user b:
> pulls up record 5                   pulls up record 5
> adds/appends line to field b        adds/appends line to field b
> clicks update first                 clicks update second
> 
> user b's line is added/appended to record 5, user a's line is
> overwritten not even seen.
> 
> Ron

Is this what you mean?

$data = "old";
A: SELECT data FROM table WHERE id=5; ## get "old";
B: SELECT data FROM table WHERE id=5; ## get "old";
A: $data .= " updated_by_A"; 
B: $data .= " updated_by_B";
A: UPDATE table SET data='$data' WHERE id=5; ## data is "old updated_by_A"
now
B: UPDATE table SET data='$data' WHERE id=5; ## data is "old updated_by_B"
now

But you want the last data to be "old updated_by_A updated_by_B". If that
is what you mean, then I think you can't solve it with transaction.

$data = "old";
A: START TRANSACTION;
A: SELECT data FROM table WHERE id=5; ## get "old"
B: START TRANSACTION;
B: SELECT data FROM table WHERE id=5; ## still get "old"
A: $data .= " updated_by_A";
B: $data .= " updated_by_B";
A: UPDATE table SET data='$data' WHERE id=5;
B: UPDATE table SET data='$data' WHERE id=5; ## waiting for A to commit
A: COMMIT; ## data is "old updated_by_A" now
B: COMMIT; ## data is "old updated_by_B" now (same as above)

Maybe you should use LOCK TABLE.



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to