/** * extends standard delete method to remove all the treatments. * * (non-PHPdoc) * @see CActiveRecord::delete() */ public function delete() { $transaction = Yii::app()->db->getCurrentTransaction() === null ? Yii::app()->db->beginTransaction() : false; try { foreach ($this->readings as $reading) { if (!$reading->delete()) { throw new Exception('Delete reading failed: ' . print_r($reading->getErrors(), true)); } } if (parent::delete()) { if ($transaction) { $transaction->commit(); } } else { throw new \Exception('unable to delete'); } } catch (\Exception $e) { if ($transaction) { $transaction->rollback(); } throw $e; } }
/** * @see cleanUpSecondaryDiagnosis() * @see parent::delete() * * @return bool */ public function delete() { $this->cleanUpSecondaryDiagnosis(); return parent::delete(); }
/** * extends standard delete method to remove any risk assignments made to it * * (non-PHPdoc) * @see CActiveRecord::delete() */ public function delete() { $transaction = Yii::app()->db->getCurrentTransaction() === null ? Yii::app()->db->beginTransaction() : false; try { foreach ($this->risk_assignments as $riska) { $riska->delete(); } foreach ($this->answers as $answer) { $answer->delete(); } if (parent::delete()) { if ($transaction) { $transaction->commit(); } } else { throw new Exception('unable to delete'); } } catch (Exception $e) { if ($transaction) { $transaction->rollback(); } throw $e; } }