try function copytest($id) { $this->Applicant->id = $id; $this->data = $this->Applicant->read(); $this->Applicant->id = null; unset($this->data['Applicant']['id']); $this->data['Applicant']['schoolyear_id'] = 16; $this->Applicant->save($this->data['Applicant']); }
or what I usually do function copytest($id) { $this->Applicant->id = $id; $this->data = $this->Applicant->read(); $this->Applicant->create(); // create a new record for saving unset($this->data['Applicant']['id']); $this->data['Applicant']['schoolyear_id'] = 16; $this->Applicant->save($this->data['Applicant']); } HTH sdevore On 9/15/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Thanks for the reply. > > I tried unsetting the 'id' value, but most strangely, the result is > that it changes the original record anyway! > > I've tried it a dozen times, just to make sure, but that is indeed what > is happening. > > function copytest($id) > { > $this->Applicant->id = $id; > $this->data = $this->Applicant->read(); > unset($this->data['Applicant']['id']); > $this->data['Applicant']['schoolyear_id'] = 16; > > $this->Applicant->save($this->data['Applicant']); > } > > > If I pass it $id = 1, then it modifies record 1 in the database and > sets the schoolyear = 16. > > If instead, I use this code: > > function copytest($id) > { > $this->Applicant->id = $id; > $this->data = $this->Applicant->read(); > $this->data['Applicant']['id'] = null; > $this->data['Applicant']['schoolyear_id'] = 16; > > $this->Applicant->save($this->data['Applicant']); > } > > > It leaves record 1 alone, and creates a copy into record 2 with > schoolyear = 16 -- which is exactly what I want, EXCEPT that it also > creates copies into record 3 and record 4, both with schoolyear = 16 as > well. > > Any ideas? > > > > > -- == S. DeVore (the old fart) the advice is free, the lack of crankiness will cost you --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---