S
S
Sergey2015-05-22 03:03:53
Yii
Sergey, 2015-05-22 03:03:53

How to display current user info table with DAO in Yii2?

There is a controller

public function actionIndex()
    {
        $dataProvider = new ActiveDataProvider([
            'query' => Transactions::find(),
        ]);

        return $this->render('index', [
            'dataProvider' => $dataProvider,
        ]);
    }

view
<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
               'id',
                'number',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>

Tell me how to apply DAO and display the table in the view.
Preferably with an example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NightGhost, 2015-05-22
@alekskondr

You make a request through DAO, and create an ArrayDataProvider instead of an ActiveDataProvider.

$provider = new ArrayDataProvider([
    'allModels' => $users,
]);

View similarly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question