public function clearDebtors() { // exclusion if ($recovery = Model_Debt_Recovery::find_by_id($this->DebtRecoveryId)) { foreach (Model_Debt_Recovery_Run::find_all_by_debt_recovery_id($recovery->id) as $run) { // find message count if (Model_Message_Log::count(array('conditions' => array('debt_recovery_id = ?', $run->id)) == 0)) { $run->delete(); } } } $this->Debtors = array(); return $this; }