function StatementPrefetchIterator::setFetchMode

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

Overrides StatementInterface::setFetchMode

1 call to StatementPrefetchIterator::setFetchMode()
StatementPrefetchIterator::execute in core/lib/Drupal/Core/Database/StatementPrefetchIterator.php
Executes a prepared statement.

File

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

Class

StatementPrefetchIterator
An implementation of StatementInterface that prefetches all data.

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.');
    $this->defaultFetchStyle = $mode;
    switch ($mode) {
        case \PDO::FETCH_CLASS:
            $this->fetchOptions['class'] = $a1;
            if ($a2) {
                $this->fetchOptions['constructor_args'] = $a2;
            }
            break;
        case \PDO::FETCH_COLUMN:
            $this->fetchOptions['column'] = $a1;
            break;
        case \PDO::FETCH_INTO:
            $this->fetchOptions['object'] = $a1;
            break;
    }
}

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