After you get the record, unset $this->Applicant->id:function copytest($id) { $this->Applicant->id = $id; $this->data = "" unset($this->data['Applicant']['id']); unset($this->Applicant->id = $id;); $this->data['Applicant']['schoolyear_id'] = 16; $this->Applicant->save($this->data['Applicant']); }I didnt test it, but this may help. Brian French [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 = "" 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->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? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
- Copying a db record [EMAIL PROTECTED]
- Re: Copying a db record John Zimmerman
- Re: Copying a db record [EMAIL PROTECTED]
- Re: Re: Copying a db record Samuel DeVore
- Re: Copying a db record Brian French
- Re: Copying a db record [EMAIL PROTECTED]
- Re: Copying a db record nate
- Re: Copying a db record [EMAIL PROTECTED]
- Re: Re: Copying a db recor... Samuel DeVore
- Re: Copying a db record [EMAIL PROTECTED]
- Re: Copying a db record Brian French
- Re: Copying a db record [EMAIL PROTECTED]
- Re: Copying a db record Sohei Okamoto
- Re: Copying a db record [EMAIL PROTECTED]
- Re: Copying a db record [EMAIL PROTECTED]