function StatementBase::fetchField

Returns a single field from the next record of a result set.

Parameters

int $index: The numeric index of the field to return. Defaults to the first field.

Return value

mixed A single field from the next record, or FALSE if there is no next record.

Overrides StatementInterface::fetchField

1 call to StatementBase::fetchField()
StatementPrefetchIterator::fetchColumn in core/lib/Drupal/Core/Database/StatementPrefetchIterator.php

File

core/lib/Drupal/Core/Database/Statement/StatementBase.php, line 308

Class

StatementBase
StatementInterface base implementation.

Namespace

Drupal\Core\Database\Statement

Code

public function fetchField($index = 0) {
  $column = $this->result
    ->fetch(FetchAs::Column, [
    'column' => $index,
  ]);
  if ($column === FALSE) {
    $this->markResultsetFetchingComplete();
    return FALSE;
  }
  $this->setResultsetCurrentRow($column);
  return $column;
}

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