var_dump($dataProvider);
抛出以下输出:
.
.
.
19 =>
object(app\models\Bewerbungen)[219]
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=12)
...
private '_oldAttributes' (yii\db\BaseActiveRecord) =>
array (size=12)
...
private '_related' (yii\db\BaseActiveRecord) =>
array (size=2)
...
private '_errors' (yii\base\Model) => null
private '_validators' (yii\base\Model) => null
private '_scenario' (yii\base\Model) => string 'default' (length=7)
private '_events' (yii\base\Component) =>
array (size=0)
...
private '_behaviors' (yii\base\Component) =>
array (size=0)
...
private '_totalCount' (yii\data\BaseDataProvider) => int 44
private '_events' (yii\base\Component) =>
array (size=0)
empty
private '_behaviors' (yii\base\Component) => null
我只需要跟随var_dump()的值:
private '_totalCount' (yii\data\BaseDataProvider) =>int 44
任何想法如何挑选$ dataProvider的这个值。我尝试了几个foreach() - 循环,但我没有成功
答案 0 :(得分:4)
私有属性不是(直接)可访问的,但您可以使用explict函数来访问属性,例如:
$count = $dataProvider->getCount();
请参阅http://www.yiiframework.com/doc-2.0/guide-output-data-providers.html
http://www.yiiframework.com/doc-2.0/yii-data-activedataprovider.html http://www.yiiframework.com/doc-2.0/yii-data-sqldataprovider.html http://www.yiiframework.com/doc-2.0/yii-data-arraydataprovider.html