public function actionDelete($id)
{
$model = PostComment::findComment($id);
if (!$model->isCurrent()) {
throw new NotFoundHttpException();
}
// 事物 暂时数据库类型不支持 无效
$transaction = \Yii::$app->db->beginTransaction();
$updateComment = $model->updateCounters(['status' => -1]);
$updateNotify = Notification::updateAll(['status' => 0], ['comment_id' => $model->id]);
$updateTopic = Topic::updateAllCounters(['comment_count' => -1], ['id' => $model->post_id]);
if ($updateNotify && $updateComment && $updateTopic) {
$transaction->commit();
} else {
$transaction->rollback();
}
return $this->redirect(['/topic/default/view', 'id' => $model->post_id]);
}