yiisoft / yii2-redis

Yii 2 Redis extension.
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
451 stars 183 forks source link

Restful resources pagination with [yii\redis\ActiveRecord] + [yii\data\ActiveDataProvider] problem #84

Open yii-bot opened 8 years ago

yii-bot commented 8 years ago

This issue has originally been reported by @phuczeero at https://github.com/yiisoft/yii2/issues/12961. Moved here by @samdark.


What steps will reproduce the problem?

Token.php

namespace app\models;

class Token extends \yii\redis\ActiveRecord
{
    public function attributes()
    {
        return ['id', 'token', 'user_id'];
    }
}

TokenController.php

namespace app\modules\v2\controllers;
use app\models\Token;

class TransferController extends \yii\rest\Controller
{
    public function actionIndex()
    {
        return new \yii\data\ActiveDataProvider([
            'query' => Token::find()->where([
                'user_id' => Yii::$app->user->id,
            ]),
        ]);
    }
}

What is the expected result?

X-Pagination-Current-Page →1
X-Pagination-Page-Count →2
X-Pagination-Per-Page →20
X-Pagination-Total-Count →30

What do you get instead?

X-Pagination-Current-Page →1
X-Pagination-Page-Count →0
X-Pagination-Per-Page →20
X-Pagination-Total-Count →0

Additional info

Q A
Yii version 2.0.10, master
PHP version 7.0.0
Operating system 64-bit Windows 7 Professional SP1
jsopra commented 5 years ago

up

Geowan commented 4 years ago

Am also facing the same issue, anyone with a solution for it?