Skip to content

Query each method does not recognize if there are no more rows #10023

@aliechti

Description

@aliechti

Like mentioned in: #9962 there is a problem with the recognition of the end of a resultset.

Example:
There is a table with 10 entries

foreach ($query->each() as $key => $value) {
    echo $key."\n";
}

after it selects the 10th row it throws an exception:

Exception 'PDOException' with message 'SQLSTATE[IMSSP]:
There are no more rows in the active result set.
Since this result set is not scrollable, no more data may be retrieved.'

in vendor\yiisoft\yii2\db\DataReader.php:111

Stack trace:
#0 vendor\yiisoft\yii2\db\DataReader.php(111): PDOStatement->fetch()
#1 vendor\yiisoft\yii2\db\BatchQueryResult.php(143): yii\db\DataReader->read()
#2 vendor\yiisoft\yii2\db\BatchQueryResult.php(112): yii\db\BatchQueryResult->fetchData()
#3 commands\TestController.php(26): yii\db\BatchQueryResult->next()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions