/** author wawan * close Berita model. * If close is successful, delete bt0001notify and return true. * @return mixed */ public function actionCloseBerita() { if (Yii::$app->request->isAjax) { $request = Yii::$app->request; $id = $request->post('id'); $kd_ref = $request->post('kd_ref'); $connection = Yii::$app->db_widget; $transaction = $connection->beginTransaction(); try { $connection->createCommand()->update('bt0001', ['STATUS' => 0], 'KD_BERITA="' . $id . '"')->execute(); if (count($kd_ref) != 0) { $issue = Issuemd::findOne(['ID_ISSUE_REF' => $kd_ref]); $issue->STATUS = 3; $issue->save(); } $close = $connection->createCommand('DELETE FROM bt0001notify WHERE KD_BERITA=:kd_berita'); $close->bindParam(':kd_berita', $kd_berita); $kd_berita = $id; $close->execute(); $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } return true; } }
/** * Finds the Issuemd model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Issuemd the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Issuemd::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }