Thanks for posting the solution. Well I've got the same problem! But it looks like you have the fix. However I can't quite get my head around it because in your example you refer to $category in
$category["CandidateItem"]["CandidateItem"][$count] = this->Category- >CandidateItem->getLastInsertID(); But where does that $category come from? Is it the $this->data ['Category']? In which case should it be $category["Candidate"] ["CandidateItem"]? Seb On Jul 14, 10:02 pm, cc_humbry <conrad.cramp...@gmail.com> wrote: > Finally sorted this for anyone else who has the sameproblem... > iterate over my array and save each item individually. Get each id of > inserted row and add to new data array and then save Category. This > then creates the associations in the link table. > > foreach($items as $item) { > $data = array(); > > $data["CandidateItem"]["title"] = $item; > > $data["CandidateItem"]["category_id"] = $categoryId; > > > $this->Category->CandidateItem->create($data); > > $this->Category->CandidateItem->save($data); > > $category["CandidateItem"]["CandidateItem"][$count] = > $this->Category->CandidateItem->getLastInsertID(); > > $count++; > } > } > } > $this->Category->create($category); > $this->Category->save($category); > > not entirely sure if this is the correct 'Cake' way of doing things > but hey, I am new to this and it works (as far as I can tell). > > Conrad --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---