Practice::delete PHP Method

delete() public method

Extend parent behaviour to enforce a transaction so that we don't lose commissioning body assignments if the delete fails part way through.
public delete ( ) : boolean
return boolean
    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;
        }
    }