Пример #1
0
 public function actionView($postid)
 {
     $model = Posts::find()->where(['post_id' => $postid])->rightJoin('users', '`users`.`user_id` = `posts`.`post_author`')->one();
     $model->updateCounters(array('post_views' => 1));
     $model->save();
     //print_r($model->users[0][user_name]);
     return $this->render('view', ['post' => $model]);
 }
Пример #2
0
 public function actionView()
 {
     $query = Posts::find()->with('users', 'postsCategory');
     $pagination = $this->getPagination($query);
     $model = $query->offset($pagination->offset)->limit($pagination->limit)->all();
     //print_r($posts[0]->users[0][user_name]);
     return $this->render('view', ['posts' => $model, 'pagination' => $pagination]);
 }
Пример #3
0
 public function getPosts()
 {
     return $this->hasOne(Posts::className(), ['post_category' => 'category_id']);
 }
Пример #4
0
 public function getPosts()
 {
     return $this->hasOne(Posts::className(), ['post_author' => 'user_id']);
 }