function StatementPrefetchIterator::fetchAll

Returns an array containing all of the result set rows.

Parameters

$mode: One of the \PDO::FETCH_* constants.

$column_index: If $mode is \PDO::FETCH_COLUMN, the index of the column to fetch.

$constructor_arguments: If $mode is \PDO::FETCH_CLASS, the arguments to pass to the constructor.

Return value

array An array of results.

Overrides StatementInterface::fetchAll

File

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

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) {
    if (isset($mode) && !in_array($mode, $this->supportedFetchModes)) {
        @trigger_error('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED);
    }
    $fetchStyle = $mode ?? $this->defaultFetchStyle;
    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.