// remove belongs_to relation $article = Model_Article::query()->related('user')->where('id', 1)->get_one(); $article->user = null; $article->save(); // alternative method for belongs_to, change the foreign key (don't use both!) $article = Model_Article::query()->related('user')->where('id', 1)->get_one(); $article->user_id = null; $article->save(); // remove has_one relation $user = Model_User::query()->related('profile')->where('id', 5)->get_one(); $user->profile = null; $user->save(); // remove has_many relation with article id 1 $user = Model_User::query()->related('articles')->where('id', 5)->get_one(); unset($user->articles[1]); $user->save(); // remove many_many relation with group id 3 $user = Model_User::query()->related('groups')->where('id', 5)->get_one(); unset($user->groups[3]); $user->save(); // remove all relations for has_many or many_many $user = Model_User::query()->related('groups')->where('id', 5)->get_one(); $user->groups = array(); $user->save();
You shouldn't get the error, nothing here should touch either teh members.id or member_details.id. This is either a bug or faulty configuration.is there an other way of deleting with cascade_delete = true without getting the error?
For has-many/belongs-to the answer is always no, deleting one of the many objects belonging to the parent object should never delete the parent because that would also trigger deletion of all the other childeren - something that is probably never your intention. In has-one/belongs-to things are less clear, this is up to you. Should deleting the Model_Member_Detail instance also delete the Model_Member instance to which is belongs?do I only set cascade_delete = true on has_one or also at belongs_to?
It looks like you're new here. If you want to get involved, click one of these buttons!