YII 列表调用和内容页

文章描述:

Yii列表和详情页调用数据

列表

public function actionIndex() {
	$this->layout='main';
	$model = User::find();
	$pages = new Pagination([‘totalCount’ =>$model->count(), 'pageSize' => '10']);
	$model = $model->offset($pages->offset)->limit($pages->limit)->all();
	return $this->render('index',[
		'model' => $model,
		'pages' => $pages,
	]);
}

内容

public function actionItem() {
	$id = Yii::$app->request->getQueryParam('id');
	if($item = User::find()->asArray()->where(['id' => $id])->one()) {
		return $this->render('item',['item' => $item,'items'=>1]);
	}
}

 

发布时间:2022/10/10

发表评论