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]); }
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]); }
public function getPosts() { return $this->hasOne(Posts::className(), ['post_category' => 'category_id']); }
public function getPosts() { return $this->hasOne(Posts::className(), ['post_author' => 'user_id']); }