How do I modify a field before update? ActiveRow is read-only; use update() method instead

Notice: This thread is very old.
frocco
Member | 46
+
0
-

Hello,

Here is my code, when the record is updated, I want to also record the user id.

$user = $this->getUser();
$id = $this->getParameter('id');
$data = $this->database->table('news')->get($id);
$data->updated_by = $user->id;
$data->update($values);

Thank you

petr.jirous
Member | 128
+
0
-
$values['updated_by'] = $user->id;
$data->update($values);
frocco
Member | 46
+
0
-

Thank you