Ejemplo n.º 1
0
 public function actionAlbum($id)
 {
     $album = DictEnAlbum::findOne($id);
     // $totalCount = \Yii::$app->db->createCommand('select count(*) from tbl_dict_en2album where albumId='.$id)->queryScalar();
     // $pages = new Pagination(['totalCount' => $totalCount]);
     // $DictEnIds = \Yii::$app->db->createCommand('select wordId from tbl_dict_en2album where albumId='.$id.' limit '.$pages->offset.' , '.$pages->limit)->queryColumn();
     // $words = DictEn::find()->where('id in('.implode(',', $DictEnIds).')')->all();
     $query = DictEn::find()->join('INNER JOIN', 'tbl_dict_en2album', 'tbl_dict_en2album.albumId=' . $id . ' and tbl_dict_en2album.wordId = tbl_dict_en.id');
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $words = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('../album/view', ['model' => $album, 'words' => $words, 'pages' => $pages]);
 }
Ejemplo n.º 2
0
 /**
  * Finds the DictEnAlbum model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return DictEnAlbum the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DictEnAlbum::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }