wollte nur mal dieses bisschen Code hier Posten, mir hilft es sehr
bewirkt das alle associations entfertn werden, ausser denen die man ausschließt, sehr toll wenn Applikationen wachsen
<?php
class AppModel extends Model {
function unbindAll($params = array()){
foreach($this->__associations as $ass){
if(!empty($this->{$ass})){
$this->__backAssociation[$ass] = $this->{$ass};
if(isset($params[$ass])){
foreach($this->{$ass} as $model => $detail){
if(!in_array($model,$params[$ass])){
$this->__backAssociation = array_merge($this->__backAssociation, $this->{$ass});
unset($this->{$ass}[$model]);
}
}
} else {
$this->__backAssociation = array_merge($this->__backAssociation, $this->{$ass});
$this->{$ass} = array();
}
}
}
return true;
}
}
?>