/** * Extend parent behaviour to enforce a transaction so that we don't lose commissioning * body assignments if the delete fails part way through. * * @return bool * * @throws Exception */ public function delete() { // perform this process in a transaction if one has not been created $transaction = Yii::app()->db->getCurrentTransaction() === null ? Yii::app()->db->beginTransaction() : false; try { if (parent::delete()) { if ($transaction) { $transaction->commit(); } return true; } else { if ($transaction) { $transaction->rollback(); } return false; } } catch (Exception $e) { if ($transaction) { $transaction->rollback(); } throw $e; } }
/** * Deletes issues for this event before calling the parent delete method * Does not handle the removal of elements and will therefore fail if this has not been handled before being called. * * @return bool * * @see parent::delete() */ public function delete() { // Delete related EventIssue::model()->deleteAll('event_id = ?', array($this->id)); return parent::delete(); }
public function delete() { if ($this->children) { foreach ($this->children as $child) { if (!$child->delete()) { return false; } } } return parent::delete(); }