Yii::$app->request->queryParams

Hey, how are you all?

Someone can tell me how to get an especific param from this lane?

In my code I want to get wk_liq_ana_cli_nro_oc from:


Yii::$app->request->queryParams

All the code for more information:




public function actionIndex()

    {

        $searchModel = new LaboratorioAlfaSearch();

	$dataProvider = $searchModel->search(Yii::$app->request->queryParams);		

        

		if ($dataProvider->getTotalCount() == 0) {

			

			$analisisClinicosVista = VLaboratorioAlfa::findAll([v_nro_oc => Yii::$app->getRequest()->getQueryParam('wk_liq_ana_cli_nro_oc')]);

						

			foreach ($analisisClinicosVista as $analisis) {

				

				LaboratorioAlfa::registrarAnalisisClinicoDesdeVista($analisis);

				

			}

		}

		

		return $this->render('index', [

                'searchModel' => $searchModel,

                'dataProvider' => $dataProvider,

        ]);			

	}



If I do:


var_dump(Yii::$app->request->queryParams);exit;

returns me: array(2) { ["r"]=> string(22) "laboratorio-alfa/index" ["LaboratorioAlfaSearch"]=> array(1) { ["wk_liq_ana_cli_nro_oc"]=> string(5) "78610" } }

But if I do:


var_dump(Yii::$app->getRequest()->getQueryParam('wk_liq_ana_cli_nro_oc'));exit;

returns me NULL :mellow:

Thanks thanks thanks!

Probably Yii::$app->request->queryParams[‘v_nro_oc’].

Now this returns me: Illegal offset type in isset or empty :blink:


var_dump(Yii::$app->request->getQueryParam(['wk_liq_ana_cli_nro_oc']));exit;

Yes, my bad, I agree getQueryParam is a better choice. But it probably won’t take an array as input, just the parameter name.

Thanks thanks thanks!