/** * Finds the Preferences model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Preferences the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Preferences::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionResultsb21afmorg() { if (!isset($_POST['select_orgs']) || empty($_POST['select_orgs'])) { $orgID1 = Preferences::findOne(['pref_name' => 'Resultsb21afmorgID']); $orgID = $orgID1->pref_value; Preferences::deleteAll(['pref_name' => 'Resultsb21afmorgID']); } else { $orgID = $_POST['select_orgs']; } if (!isset($_POST['set_afm']) || empty($_POST['set_afm'])) { $afm1 = Preferences::findOne(['pref_name' => 'Resultsb21afmorgcpv']); $afm = $afm1->pref_value; Preferences::deleteAll(['pref_name' => 'Resultsb21afmorgcpv']); } else { $afm = $_POST['set_afm']; } Preferences::deleteAll(['pref_name' => 'Resultsb21afmorgID']); Yii::$app->view->params['Resultsb21afmorgID'] = $orgID; $pref = new Preferences(); $pref->pref_name = 'Resultsb21afmorgID'; $pref->pref_value = $orgID; $pref->save(); Preferences::deleteAll(['pref_name' => 'Resultsb21afmorgcpv']); Yii::$app->view->params['Resultsb21afmorgcpv'] = $afm; $pref = new Preferences(); $pref->pref_name = 'Resultsb21afmorgcpv'; $pref->pref_value = $afm; $pref->save(); return $this->render('resultsb21afmorg'); }