function StatementWrapperIterator::setFetchMode

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

Overrides StatementInterface::setFetchMode

4 calls to StatementWrapperIterator::setFetchMode()
StatementWrapperIterator::execute in core/lib/Drupal/Core/Database/StatementWrapperIterator.php
Executes a prepared statement.
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::__construct in core/lib/Drupal/Core/Database/StatementWrapperIterator.php
Constructs a StatementWrapperIterator object.

File

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

Class

StatementWrapperIterator
StatementInterface iterator implementation.

Namespace

Drupal\Core\Database

Code

public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
    assert(in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.');
    // Call \PDOStatement::setFetchMode to set fetch mode.
    // \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()) {    1 => $this->clientStatement
            ->setFetchMode($mode),
        2 => $this->clientStatement
            ->setFetchMode($mode, $a1),
        default => $this->clientStatement
            ->setFetchMode($mode, $a1, $a2),
    
    };
}

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