/**
  * Updates an existing OrdersTransport model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     //$model = $this->findModel($id);
     $sql = "SELECT * FROM assign WHERE id = '{$id}' AND (oil != '' AND now_mile != '')";
     $rs = Yii::$app->db->createCommand($sql)->queryOne();
     if (!empty($rs)) {
         $error = "1";
         return $this->redirect(['index', 'error' => $error]);
     } else {
         $model = Assign::findOne($id);
         return $this->render('//assign/update', ['model' => $model, 'assign_id' => $model->assign_id]);
     }
 }
示例#2
0
 /**
  * Finds the Assign model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Assign the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Assign::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }