public function actionView($id)
{
$model = $this->findModel($id);
$related = News::find();
$related->andFilterWhere(['like', 'subject', $model->subject])
->orderBy(['id' => SORT_DESC])
->queryAll();
return $this->render('view', [
'model' => $model,'related'=>$related
]);
}
我收到此错误:
未知方法 - yii \ base \ UnknownMethodException 调用未知方法:frontend \ models \ NewsQuery :: queryAll()
有人可以告诉我我的错误吗?
答案 0 :(得分:1)
将其更改为:
public function actionView($id)
{
$model = $this->findModel($id);
$related = News::find();
$related->andFilterWhere(['like', 'subject', $model->subject])
->orderBy(['id' => SORT_DESC]);
return $this->render('view', [
'model' => $model,'related' => $related->all()
]);
}