How to update row in Nette 2.1

Notice: This thread is very old.
barbucha
Member | 11
+
0
-

Hello,
after upgrade to Nette 2.1 update to database doesn't work.
My code is

<?php
/**
  @param $where - where parameters for update selection
  @param $values - new values
*/
public function updateInput($where, $values)
    {
        $query = $this->database->table('input');
        foreach ($where as $k => $v) {
            $query->where($k, $v);
        }
        $row = $query->fetch();
        return $row->update($values);
    }
?>

This is the error text that appears when trying to use this function:
Nette\DeprecatedException: ActiveRow is read-only; use update() method instead.

What's wrong
Thanks for your help.

bazo
Member | 620
+
-3
-

use your brain, the error message says it clearly.

$row->update([…])

petr.pavel
Member | 535
+
0
-

@bazo: I don't follow your comment. The advise is to use update() method which he does. He's not doing $row['something'] = 'value';
As far as I know $row->update() is valid. I use it in 2.1.2 and it works.

@barbucha: Are you sure the error is triggered in the code you provided? My best shot is that elsewhere you are indeed, setting a value with array access: $row['attr'] = 'val';

barbucha
Member | 11
+
0
-

@petr.pavel You are right, the problem was elsewhere.
Thanks.