function StatementWrapperIterator::fetch

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

Overrides StatementInterface::fetch

3 calls to StatementWrapperIterator::fetch()
StatementWrapperIterator::fetchAllAssoc in core/lib/Drupal/Core/Database/StatementWrapperIterator.php
Returns the result set as an associative array keyed by the given field.
StatementWrapperIterator::fetchAllKeyed in core/lib/Drupal/Core/Database/StatementWrapperIterator.php
Returns the entire result set as a single associative array.
StatementWrapperIterator::fetchAssoc in core/lib/Drupal/Core/Database/StatementWrapperIterator.php
Fetches the next row and returns it as an associative array.

File

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

Class

StatementWrapperIterator
StatementInterface iterator implementation.

Namespace

Drupal\Core\Database

Code

public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = 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);
    }
    // Call \PDOStatement::fetchAll to fetch all rows.
    // \PDOStatement is picky about the number of arguments in some cases so we
    // need to pass the exact number of arguments we were given.
    $row = match (func_num_args()) {    0 => $this->clientStatement
            ->fetch(),
        1 => $this->clientStatement
            ->fetch($mode),
        2 => $this->clientStatement
            ->fetch($mode, $cursor_orientation),
        default => $this->clientStatement
            ->fetch($mode, $cursor_orientation, $cursor_offset),
    
    };
    if ($row === FALSE) {
        $this->markResultsetFetchingComplete();
        return FALSE;
    }
    $this->setResultsetCurrentRow($row);
    return $row;
}

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