yiisoft/yii2 · error · yii\base\InvalidCallException

DataReader cannot rewind. It is a forward-only reader.

Error message

DataReader cannot rewind. It is a forward-only reader.

What it means

Error "DataReader cannot rewind. It is a forward-only reader." thrown in yiisoft/yii2.

Source

Thrown at framework/db/DataReader.php:230

     */
    public function getColumnCount()
    {
        return $this->_statement->columnCount();
    }

    /**
     * Resets the iterator to the initial state.
     * This method is required by the interface [[\Iterator]].
     * @throws InvalidCallException if this method is invoked twice
     */
    #[\ReturnTypeWillChange]
    public function rewind()
    {
        if ($this->_index < 0) {
            $this->_row = $this->_statement->fetch();
            $this->_index = 0;
        } else {
            throw new InvalidCallException('DataReader cannot rewind. It is a forward-only reader.');
        }
    }

    /**
     * Returns the index of the current row.
     * This method is required by the interface [[\Iterator]].
     * @return int the index of the current row.
     */
    #[\ReturnTypeWillChange]
    public function key()
    {
        return $this->_index;
    }

    /**
     * Returns the current row.
     * This method is required by the interface [[\Iterator]].
     * @return mixed the current row.

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/db/DataReader.php:230 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17). Data as JSON: /api/errors/e4d1e895352ec112. Report an issue: GitHub.