What about updateAll() ? $this->User->updateAll( array('User.status' => 'active'), array('User.id' => 1) );
Seems pretty straightforward to me... On Dec 18, 7:12 am, gearvOsh <mileswjohn...@gmail.com> wrote: > I still have yet to find a straight forward way to do this, so ill > simply do something like this: > > function update($user_id, $fields) { > if (is_array($fields)) { > App::import('Sanitize'); > Sanitize::clean($fields); > > $cleanFields = array(); > foreach ($fields as $field => $value) { > $cleanFields[] = "User.". $field ." = '". $value ."'"; > } > > $sql = "UPDATE users AS User SET ". implode(', ', > $cleanFields) ." > WHERE User.id = ". Sanitize::escape($user_id) ." LIMIT 1"; > return $this->query($sql); > } > > return NULL; > > } --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---