OEModule\OphCiExamination\models\Element_OphCiExamination_ColourVision::delete PHP Method

delete() public method

(non-PHPdoc)
See also: CActiveRecord::delete()
public 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;
        }
    }