Vincent
Vincent

Reputation: 15

Kohana 3.2 ORM multiple records update

How can I update multiple records in Kohana 3.2's ORM?

For example this:

$menu = ORM::factory('menu');
$menu->where('active','=',1);
$menu->active=2;
$menu->save();

does not work, it inserts a new record.

Thanks

Upvotes: 1

Views: 4542

Answers (1)

Evulse
Evulse

Reputation: 46

If you don't want to hardcode the table name maybe something like below

DB::update(ORM::factory('menu')->table_name())
->set(array('active' => '2'))
->where('active', '=', '1')
->execute();

Upvotes: 3

Related Questions