shohyuken Setiawan wrote on Tuesday 2nd of August 2011:I have a model that has_many other models that i need to remove selectively/update let's use the Model_User has many Model_Comment example.
Say that I have a page where user page that can select multiple comments or update multiple comments.
I can think of 2 ways:
1. delete all the comments by calling $model_user->comments = null and then save it and re add them (easiest way)
2. loop through and update/delete selectively , which is faster I am opting for the second one, I manage to do the update by looping manually and comparing the content see if it's updated (is there a better way?)
but I can't selectively delete certain comments out i tried unsetting it based on the index and it didnt work
$comment_ids = array(); foreach ($comments as $comment) { array_push($comment_ids, $comment->id); } $num = \DB::delete('comments')->where_in('id', $comment_ids)->execute();
It looks like you're new here. If you want to get involved, click one of these buttons!