答案 0 :(得分:4)
正如@ 3dgoo所述,您可以删除onBeforeDelete()
(api docs)方法中的相关内容。
$has_one = [
'Foo' => 'SomeDataobject'
];
/**
* gets called before this item is finally deleted,
* deletes the related "SomeDataObject" also
*/
public function onBeforeDelete()
{
if ($this->FooID) {
$this->Foo()->delete();
}
}