public function acProblem() { $cid = '16'; $posts = Post::find()->where(['category_id' => $cid])->limit(10)->orderBy('id desc')->all(); return $this->view('problem', ['posts' => $posts]); }
/** * @return \yii\db\ActiveQuery */ public function getPost() { return $this->hasMany(Post::className(), ['category_id' => 'id']); }