function StatementPrefetch::fetchColumn

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Database/StatementPrefetch.php \Drupal\Core\Database\StatementPrefetch::fetchColumn()
  2. 8.9.x core/lib/Drupal/Core/Database/StatementPrefetch.php \Drupal\Core\Database\StatementPrefetch::fetchColumn()
1 call to StatementPrefetch::fetchColumn()
StatementPrefetch::fetchField in core/lib/Drupal/Core/Database/StatementPrefetch.php
Returns a single field from the next record of a result set.

File

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

Class

StatementPrefetch
An implementation of StatementInterface that pre-fetches all data.

Namespace

Drupal\Core\Database

Code

public function fetchColumn($index = 0) {
  if (isset($this->currentRow) && isset($this->columnNames[$index])) {
    // We grab the value directly from $this->data, and format it.
    $return = $this->currentRow[$this->columnNames[$index]];
    $this->next();
    return $return;
  }
  else {
    return FALSE;
  }
}

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