function StatementPrefetch::setFetchMode

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

Overrides StatementInterface::setFetchMode

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

File

core/lib/Drupal/Core/Database/StatementPrefetch.php, line 290

Class

StatementPrefetch
An implementation of StatementInterface that prefetches all data.

Namespace

Drupal\Core\Database

Code

public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
    $this->defaultFetchStyle = $mode;
    switch ($mode) {
        case \PDO::FETCH_CLASS:
            $this->defaultFetchOptions['class'] = $a1;
            if ($a2) {
                $this->defaultFetchOptions['constructor_args'] = $a2;
            }
            break;
        case \PDO::FETCH_COLUMN:
            $this->defaultFetchOptions['column'] = $a1;
            break;
        case \PDO::FETCH_INTO:
            $this->defaultFetchOptions['object'] = $a1;
            break;
    }
    // Set the values for the next fetch.
    $this->fetchStyle = $this->defaultFetchStyle;
    $this->fetchOptions = $this->defaultFetchOptions;
}

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