I would suggest looking at saveAll to do the save part, then to do your addition you just need to make sure it's in the data.
That said, here's the way I handle adding a related record as shown in your add() above: function add() { if (!empty($this->data)) { $this->Record->create(); if ($this->Record->save($this->data)) { $this->data['Timespan']['record_id'] = $this->Record->getLastInsertId(); $this->data['Timespan']['debet'] = $this- >data['Record']['debet']; $this->data['Timespan']['credit'] = $this- >data['Record']['credit']; if ($this->Record->Timespan->save($this- >data)){ $this->Session->setFlash(__('The Record has been saved', true)); $this->redirect(array ('action'=>'index')); } else { $this->Session->setFlash(__('The Timespan could not be saved.',true)); } } else { $this->Session->setFlash(__('The Record could not be saved. Please, try again.', true)); } } And for places that you expect an update, you would just do your calculation and do a 'saveAll($this->data)' On Dec 2, 2:14 am, webscriptz <[EMAIL PROTECTED]> wrote: > normally i would read it out with php, put them in vars and addition > the values and resave them. > > On Dec 2, 10:49 am, webscriptz <[EMAIL PROTECTED]> wrote: > > > Sorry for that, > > > I have a model Records and Timespans. DEBET and CREDIT have to be > > inserted in the records table but also in the Timespans table in DEBET > > and CREDIT > > The first is not a problem but the second is. IT has to be additioned > > not just replaced by the latest. > > > function add() { > > if (!empty($this->data)) { > > $this->Record->create(); > > if ($this->Record->save($this->data)) { > > $this->Session->setFlash(__('The Record has > > been saved', true)); > > $this->redirect(array('action'=>'index')); > > } else { > > $this->Session->setFlash(__('The Record > > could not be saved. > > Please, try again.', true)); > > } > > } > > $timespans = $this->Record->Timespan->find('list'); > > $this->set(compact('timespans')); > > > what do I have to reference to where in fact I didn't quit get that > > and do I have to change something in the view also? > > > Thanks, > > > - Tim > > > On Dec 1, 9:40 pm, Rob <[EMAIL PROTECTED]> wrote: > > > > So just a suggestion for future questions, describe the tables and > > > their relationship in your question a little next time. > > > > Assuming you have a Records model and a Timespans model that are > > > related to each other, and the relationships are described in the > > > models for those two entities ... > > > > So, for example if you want to add the values from a Record to the > > > values in the related Timespan, you would reference the $this->Record > > > and $this->Record->Timespan > > > > On Dec 1, 1:45 am, webscriptz <[EMAIL PROTECTED]> wrote: > > > > > I'm making a register and I have a small problem, > > > > > I want two numbers to be additioned (+) with the numbers already in an > > > > other table, unfortunantly I don't know how to do this. > > > > > i have a Record with "debet" and "credit" and i want to addition them > > > > to "debet" and "credit" in timespans. > > > > > but they got controller & model records > > > > > please help, > > > > > Tim De Smedt > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---