예제 #1
0
 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();
     }
 }
예제 #2
0
 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();
     }
 }