コード例 #1
0
ファイル: TextController.php プロジェクト: suyuanen/p2p
 public function acProblem()
 {
     $cid = '16';
     $posts = Post::find()->where(['category_id' => $cid])->limit(10)->orderBy('id desc')->all();
     return $this->view('problem', ['posts' => $posts]);
 }
コード例 #2
0
ファイル: Category.php プロジェクト: suyuanen/p2p
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPost()
 {
     return $this->hasMany(Post::className(), ['category_id' => 'id']);
 }