public function actionGeneratedetail1() { if (isset($_POST['id'])) { $delv = Deliveryadvice::model()->findbypk($_POST['id']); $header; if ($delv != null) { $header = $delv->headernote; } $connection = Yii::app()->db; $transaction = $connection->beginTransaction(); try { $sql = 'call GeneratePRDA(:vid, :vhid)'; $command = $connection->createCommand($sql); $command->bindvalue(':vid', $_POST['id'], PDO::PARAM_INT); $command->bindvalue(':vhid', $_POST['hid'], PDO::PARAM_INT); $command->execute(); $transaction->commit(); if (Yii::app()->request->isAjaxRequest) { echo CJSON::encode(array('status' => 'success', 'headernote' => $header, 'div' => "Data generated")); } } catch (Exception $e) { $transaction->rollBack(); if (Yii::app()->request->isAjaxRequest) { echo CJSON::encode(array('status' => 'failure', 'div' => $e->getMessage())); } } } Yii::app()->end(); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Deliveryadvice::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }