yii2-redis icon indicating copy to clipboard operation
yii2-redis copied to clipboard

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

Open yii-bot opened this issue 8 years ago • 2 comments

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

yii-bot avatar Nov 14 '16 20:11 yii-bot

up

jsopra avatar Dec 31 '18 21:12 jsopra

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

Geowan avatar Aug 24 '20 06:08 Geowan