[eluser]Peet86[/eluser]
Thanks Phil!
It works now!
One more question:
I have multiple relation between Media and Post..
The relations have "type" join field.
Can I add some where() term for the join field when I delete?
Code:
$n = new Post();
$n->where("id",$parameters[0])->get();
$d = new Post();
$d->where("id",$parameters[0])->get();
$d->media->where_join_field($n,"type",$type)->get();
foreach($d->media->all as $image){
$n->delete($image); // this will delete all the relations of an image, but I only want to delete the image which has the value "$type" in the join field
}