yii2作为数据提供者加入模型
我加入了如下两个表:yii2作为数据提供者加入模型,yii2,Yii2,我加入了如下两个表: $model=SalesEntry::find() ->joinWith('salesItems')) ->全部(); 然后在视图中使用数据提供程序,如下所示: GridView::小部件([ “dataProvider”=>$model, “列”=>[ “date',//第一个表中的示例字段,以查看是否确定 ], ]); 我有以下错误: 对非对象调用成员函数getCount() 我做错了什么?GridView中的DataProvider应该是yii\data\Da
$model=SalesEntry::find()
->joinWith('salesItems'))
->全部();
然后在视图中使用数据提供程序,如下所示:
GridView::小部件([
“dataProvider”=>$model,
“列”=>[
“date',//第一个表中的示例字段,以查看是否确定
],
]);
我有以下错误:
对非对象调用成员函数getCount()
我做错了什么?GridView中的DataProvider应该是
yii\data\DataProviderInterface
请参阅。GridView中的DataProvider应该是
yii\data\DataProviderInterface
请参阅。GridView中的DataProvider应该是
yii\data\DataProviderInterface
请参阅。GridView中的DataProvider应该是
yii\data\DataProviderInterface
请参阅。这是因为
ActiveQuery
实例不是小部件所期望的数据提供程序。您需要将其包装在ActiveDataProvider
中才能正常工作:
GridView::widget([
'dataProvider' => new \yii\data\ActiveDataProvider(['query' => $model]),
' columns' => [
'date', // sample field from first table to see if ok
],
]);
这是因为ActiveQuery
实例不是小部件所期望的DataProvider
。您需要将其包装在ActiveDataProvider
中才能正常工作:
GridView::widget([
'dataProvider' => new \yii\data\ActiveDataProvider(['query' => $model]),
' columns' => [
'date', // sample field from first table to see if ok
],
]);
这是因为ActiveQuery
实例不是小部件所期望的DataProvider
。您需要将其包装在ActiveDataProvider
中才能正常工作:
GridView::widget([
'dataProvider' => new \yii\data\ActiveDataProvider(['query' => $model]),
' columns' => [
'date', // sample field from first table to see if ok
],
]);
这是因为ActiveQuery
实例不是小部件所期望的DataProvider
。您需要将其包装在ActiveDataProvider
中才能正常工作:
GridView::widget([
'dataProvider' => new \yii\data\ActiveDataProvider(['query' => $model]),
' columns' => [
'date', // sample field from first table to see if ok
],
]);