I had a problem with the mvc model updating a row.
The task was:
in table table_name
set column_name
= column_name
+ 1
If i would use the model like
model->find(...)
model->column_name = model->column_name + 1
model->save
then another script could have updated the column in the mean time:
model->find(...)
model->column_name = model->column_name + 1 // lets say loaded 9 and set to 10
// at this point another script may just loaded the old value 9
// and saved it to n.
// my current model would save to to 10 which would be wrong
model->save
To prevent that Im using the server:
$result = $this->getWriteConnection()->query(
"UPDATE `table_name` SET
`column_name` = @new_value := `column_name` + 1
WHERE ...;"
);
I then select the @new_value session var on another call.
What Im searching now is a way to do that with the mvc model. Any way to do that?