What about using the afterSave callback? http://book.cakephp.org/view/1053/afterSave
Jeremy Burns Class Outfit [email protected] http://www.classoutfit.com On 13 Jan 2011, at 09:21, makville wrote: > Hi, > I have a requirement in one of my models. One of the fields is > dependent on the autoincrement id so it has to be updated after the > row has been saved in the database. Something like this > > <?php > class SomeModel extends AppModel > { > .... > //override the default save function > function save ( $data = null ) > { > $r = parent::save($data); > if ( $r ) { > $this->saveField('some_field_name', 'some_value'); > } > return $r; > } > } > ?> > This saves the data correctly but crashes my apache server as an added > bonus. > > If i however remove the saveField line. It saves but does not update > the field i want updated (obviously!). And the server does not crash. > > Now if id did this instead, > <?php > class SomeModel extends AppModel > { > .... > //override the default save function > function save ( $data = null ) > { > $r = parent::save($data); > if ( $r ) { > $data['some_field_name'] = 'some_value'; > return parent->save($data); > } > } > } > ?> > It works without issues. I just have a feeling it might be more > demanding on the server. > So Community, any thoughts?... > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
