Weird thing is I tried the unset method and that didn't work either, when $show->save() was executed and the page refreshed the elements were still there.Harro Verton wrote on Friday 23rd of December 2011:Moved the post to the ORM forum. Without telling us what the errors are, or what issues you have, we can only guess. In case of update, are some related objects already present? Shouldn't you check if $show->genres[$genre] exists before adding it again? Deleting a related object is as simple as "unset($show->genre[$genre]);". They will deleted when you save the object.
Harro Verton wrote on Friday 23rd of December 2011:Cascade_save disabled on that relation? If so, $show->save() will only save the show object, and not the changes to the related objects.
// unlinked all related genres not present in $genres foreach ($show->genres as $key => $unused) { in_array($key, $genres) or unset($show->genres[$key]); } $show->save();
Harro Verton wrote on Friday 23rd of December 2011:This should be enough to delete them:
// unlinked all related genres not present in $genres foreach ($show->genres as $key => $unused) { in_array($key, $genres) or unset($show->genres[$key]); } $show->save();
It looks like you're new here. If you want to get involved, click one of these buttons!