A
A
akula222018-12-17 17:24:44
Yii
akula22, 2018-12-17 17:24:44

Pagination in yii2 with data grouping, displays the wrong amount?

There is such a complex query with data grouping and a temporary table

$subQuery = (new \yii\db\Query())
            ->from('pm')
            ->where('user_id = :user_id AND sender_id != :user_id AND status != :status ' . $w . '
            ORDER BY created_at DESC', [
                'user_id' => Yii::$app->user->id, 'status' => Pm::STATUS_DELETE]);
        $query = self::find()->select('id, text, created_at, username, sender_id, user_id, sum(unread) as noread');

        $query->from(['AS `tmp_table` GROUP BY `sender_id` ' => $subQuery]);

in the grid it displays 5 records, correct, but the pagination is not correct,
$count = $query->count(); shows 63
Tell me how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
morricone85, 2018-12-17
@morricone85

show data provider code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question