public function afterDelete() { parent::afterDelete(); //run parent event handler... if ($post = Posting::model()->findByPk($this->post_id)) { $success = $post->delete(); //delete posting record } if (is_object($this->_transaction)) { $this->_transaction->commit(); } }
public static function setPostParam($id, $paramName, $paramValue) { //DebugBreak(); $transaction = Yii::app()->db->beginTransaction(); try { $posts = Posting::model()->findByPk($id); $posts->{$paramName} = $paramValue ? self::SWITCH_ON : self::SWITCH_OFF; $posts->save(true, array($paramName)); $transaction->commit(); } catch (Exception $e) { $transaction->rollback(); } }