function StatementWrapperIterator::fetchAll

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

Overrides StatementInterface::fetchAll

1 call to StatementWrapperIterator::fetchAll()
StatementWrapperIterator::fetchCol in core/lib/Drupal/Core/Database/StatementWrapperIterator.php
Returns an entire single column of a result set as an indexed array.

File

core/lib/Drupal/Core/Database/StatementWrapperIterator.php, line 312

Class

StatementWrapperIterator
StatementInterface iterator implementation.

Namespace

Drupal\Core\Database

Code

public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
    assert(!isset($mode) || in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.');
    // Call \PDOStatement::fetchAll to fetch all rows.
    // \PDOStatement is picky about the number of arguments in some cases so we
    // need to be pass the exact number of arguments we where given.
    $return = match (func_num_args()) {    0 => $this->clientStatement
            ->fetchAll(),
        1 => $this->clientStatement
            ->fetchAll($mode),
        2 => $this->clientStatement
            ->fetchAll($mode, $column_index),
        default => $this->clientStatement
            ->fetchAll($mode, $column_index, $constructor_arguments),
    
    };
    $this->markResultsetFetchingComplete();
    return $return;
}

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