function ResultBase::fetchAll

Returns an array containing all of the result set rows.

Parameters

\Drupal\Core\Database\FetchAs $mode: One of the cases of the FetchAs enum.

array{class?: class-string, constructor_args?: list<mixed>, column?: int, cursor_orientation?: int, cursor_offset?: int} $fetchOptions: An array of fetch options.

Return value

array An array of results.

1 method overrides ResultBase::fetchAll()
PdoResult::fetchAll in core/lib/Drupal/Core/Database/Statement/PdoResult.php
Returns an array containing all of the result set rows.

File

core/lib/Drupal/Core/Database/Statement/ResultBase.php, line 79

Class

ResultBase
Base class for results of a data query language (DQL) statement.

Namespace

Drupal\Core\Database\Statement

Code

public function fetchAll(FetchAs $mode, array $fetchOptions) : array {
    $result = [];
    while ($rowAssoc = $this->fetch(FetchAs::Associative, $fetchOptions)) {
        $result[] = $this->assocToFetchMode($rowAssoc, $mode, $fetchOptions);
    }
    return $result;
}

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