public function actionUpdate($id) { $model = Rel_read::find()->where("id = {$id}")->one(); // 查询阅读关联文章,纪录片,主人公 if ($post = Yii::$app->request->post()) { $model->set_read_rel($post); // 查询阅读关联文章,纪录片,主人公 $xman = Xman::getOneById($model->xman_id); $film = Film::getOneById($model->film_id); $article = Article::getOneById($model->article_id); if ($model->save(false)) { return $this->render('update', ['msg' => '更新相关阅读成功!', 'model' => $model, 'xman' => $xman, 'film' => $film, 'article' => $article]); } else { return $this->render('update', ['msg' => '更新相关阅读失败,请刷新重试!', 'model' => $model, 'xman' => $xman, 'film' => $film, 'article' => $article]); } } else { $xman = Xman::getOneById($model->xman_id); $film = Film::getOneById($model->film_id); $article = Article::getOneById($model->article_id); return $this->render('update', ['model' => $model, 'xman' => $xman, 'film' => $film, 'article' => $article]); } }
public function actionView($id) { $film = Film::find()->where("id = {$id}")->asArray(true)->one(); $xmans = Film::findXmans($id); return $this->render('view', ['film' => $film, 'xmans' => $xmans]); }
protected function findModel($id) { if (($model = Film::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('您查找的页面不存在!'); } }
public function actionView($id) { $this->view_data['film'] = Film::find()->where("id = {$id}")->asArray()->one(); return $this->render('view', $this->view_data); }