Yii 2 ActiveDataProvider query with ->all() gives “Call to a member function andFilterWhere() on array” error

筅森魡賤 提交于 2019-12-10 11:08:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!