问题
I need to pass ActiveDataProvider object to view and I can't understand why this:
$query = Incarico::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
works, while this:
$query = Incarico::find()
->joinWith('allegatos')
->all();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
gives me the following error:
Call to a member function andFilterWhere() on array
回答1:
You should not apply all() to $query since ActiveDataProvider query property expects valid ActiveQuery instance while you are passing results of that query.
来源:https://stackoverflow.com/questions/30257838/yii-2-activedataprovider-query-with-all-gives-call-to-a-member-function-and