Finally sorted this for anyone else who has the same problem...
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 [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
-~----------~----~----~----~------~----~------~--~---