Have posted all the code that is getting run? You initially assign an instance of the model to $model, and then you use $myModel in the loop. Something smells a bit fishy, and I dont think you have included all of the code from your controller.
On Saturday, 15 December 2012 01:53:04 UTC+10, vitor gomes wrote: > > When I try to do this: > > $model = new MyModel(); > > foreach ($this->request->data['models'] as $modelId => &$modelData) { > $myModel->save(array('id' => $modelId, 'label' => > $modelData['label'])); > } > > CakePHP ORM executes 3 selects before the update. Anybody knows why it > happens? > > > It is what CakePHP ORM is executing: > > 3SELECT COUNT(*) AS `count` FROM `db`.`model` AS `MyModel` WHERE > `MyModel`.`id` > = 2110 > 4SELECT COUNT(*) AS `count` FROM `db`.`model` AS `MyModel` WHERE > `MyModel`.`id` = 2 > > > 5SELECT COUNT(*) AS `count` FROM `db`.`model` AS `MyModel` WHERE > `MyModel`.`id` > = 2 > > > 6UPDATE `db`.`model` SET `id` = 2, `label` = 'XXXXXXXX' WHERE > `db`.`model`.`id` = 2 > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.