public function actionGuarantee() { $left = About::find()->asArray()->all(); try { $cat_id = Cat::findOne(['name' => '担保机构', 'status' => 1])->id; $infos = Link::find()->where(['cat_id' => $cat_id, 'status' => 1])->all(); } catch (ErrorException $e) { $infos = ''; } return $this->render('guarantee', ['infos' => $infos, 'left' => $left]); }
/** * Finds the Cat model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Cat the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Cat::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }