function StatementIteratorTrait::rewind

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Database/StatementIteratorTrait.php \Drupal\Core\Database\StatementIteratorTrait::rewind()

Rewinds back to the first element of the Iterator.

This is the first method called when starting a foreach loop. It will not be executed after foreach loops.

@internal This method should not be called directly.

See also

https://www.php.net/manual/en/iterator.rewind.php

File

core/lib/Drupal/Core/Database/StatementIteratorTrait.php, line 105

Class

StatementIteratorTrait
StatementInterface iterator trait.

Namespace

Drupal\Core\Database

Code

public function rewind() : void {
    // Nothing to do: our DatabaseStatement can't be rewound. Error out when
    // attempted.
    // @todo convert the error to an exception in Drupal 11.
    if ($this->resultsetKey >= 0) {
        trigger_error('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.', E_USER_WARNING);
        $this->markResultsetIterable(FALSE);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.