in a CakePHP 2.3 project, in one of the controller actions I want to update several records of a table. The data to be updated is posted as an array, and I iterate through that array.
However, some new field values are related to current field values, therefore I cannot simply write the data in an array $data and do model-save($data). Instead I do
$record = model->read(null, $id); //$id is retrieved from the posted data array.
$record['some_field'] = $new_value;
unset($record['modified']);
//in addition I used model->modified = null;, but to no avail
model->save($record);
Problem is, that the field modified is not automagically updated. In the CakePHP documentation I found that the value for "Modified" must not be present in the data that is to be saved. But the unset() alone doesn't seem to be enough.
In cakePHP - modified field not updating user tadasZ mentioned that it doesn't work when you use model->read() in advance.
I couldn't find anything about it in the documentation. But if that is the case, is there any way at all to use the Automagic for the field modified? I can set the field value myswlf (in fact, right now that's what I do as a workaround), but if there is an automatic way, I would like to use it.