/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MAbout::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['about_id' => $this->about_id, 'com_tel' => $this->com_tel]); $query->andFilterWhere(['like', 'com_name', $this->com_name])->andFilterWhere(['like', 'com_addr', $this->com_addr])->andFilterWhere(['like', 'com_voice', $this->com_voice])->andFilterWhere(['like', 'com_content', $this->com_content]); return $dataProvider; }
/** * Finds the MAbout model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return MAbout the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MAbout::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionAbout() { //$about = MAbout::findOne(['about_id' => 1]); $about = MAbout::find()->one(); return $this->render('about', ['about' => $about]); }
<?php /* @var $this \yii\web\View */ /* @var $content string */ use yii\helpers\Html; use yii\bootstrap\Nav; use yii\bootstrap\NavBar; use yii\widgets\Breadcrumbs; use app\assets\AppAsset; use app\models\MAbout; use app\models\MGoodscat; use app\models\MGoods; AppAsset::register($this); $about = MAbout::find()->one(); $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <meta charset="<?php echo Yii::$app->charset; ?> "> <!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->