Ejemplo n.º 1
0
 public function actionIndex()
 {
     //处理本页面的按钮操作
     $request = Yii::$app->request;
     if ($op = $request->get('op')) {
         $id = $request->get('id');
         $film = Film::find()->where(['id' => $id])->one();
         if ($op == 'p') {
             $film->status = Film::STATUS_PUBLISHED;
         }
         if ($op == 'up') {
             $film->status = Film::STATUS_UN_PUBLISHED;
         }
         if ($op == 'd') {
             $film->status = Film::STATUS_DELETE;
         }
         $film->save(false);
     }
     // 记录片列表
     $query = Film::find()->where("status != -1");
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $films = $query->orderBy('id')->offset($pagination->offset)->limit($pagination->limit)->all();
     // 查询记录片主人公
     $film_xmans = [];
     foreach ($films as $film) {
         $film_xmans[$film->id] = $this->findXmans($film->id);
     }
     return $this->render('index', ['films' => $films, 'film_xmans' => $film_xmans, 'pagination' => $pagination, 'page' => Yii::$app->request->get('page')]);
 }
Ejemplo n.º 2
0
 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]);
 }
Ejemplo n.º 3
0
 public function actionView($id)
 {
     $this->view_data['film'] = Film::find()->where("id = {$id}")->asArray()->one();
     return $this->render('view', $this->view_data);
 }