function StatementPrefetchIterator::fetchAll

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Database/StatementPrefetchIterator.php \Drupal\Core\Database\StatementPrefetchIterator::fetchAll()

Overrides StatementInterface::fetchAll

File

core/lib/Drupal/Core/Database/StatementPrefetchIterator.php, line 299

Class

StatementPrefetchIterator
An implementation of StatementInterface that prefetches all data.

Namespace

Drupal\Core\Database

Code

public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
    $fetchStyle = $mode ?? $this->defaultFetchStyle;
    assert(in_array($fetchStyle, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$fetchStyle] ?? $fetchStyle) . ' is not supported. Use supported modes only.');
    if (isset($column_index)) {
        $this->fetchOptions['column'] = $column_index;
    }
    if (isset($constructor_arguments)) {
        $this->fetchOptions['constructor_args'] = $constructor_arguments;
    }
    $result = [];
    while ($row = $this->fetch($fetchStyle)) {
        $result[] = $row;
    }
    return $result;
}

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