key
dependent: When the dependent key is set to true, and the model's
delete() method is called with the cascade parameter set to true,
associated model records are also deleted. In this case we set it true
so that deleting a User will also delete her associated Profile.
On Jan 3, 9:56 pm, "rhythmicde...@gmail.com" <rhythmicde...@gmail.com>
wrote:
> I have a model Recipe that has a one to many relationship with a model
> IngredientList
>
> I want to delete a single recipe from the Recipe model which should
> also delete all the records from the IngredientList model that have
> the recipe's ID.
>
> I would have thought that there would be a single line command like
> there is for insert.
>
> if ($this->Recipe->saveAll($this->data))
>
> But this is only way I could find to do it:
>
> function delete($id)
> {
> $this->IngredientList->deleteAll("IngredientList.recipe_id = $id",
> true);
> $this->Recipe->del($id);
> $this->flash('The recipe with id: '.$id.' has been deleted.', '/
> recipes');
> }
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment