function StatementBase::fetch

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Database/Statement/StatementBase.php \Drupal\Core\Database\Statement\StatementBase::fetch()

Fetches the next row from a result set.

Parameters

\Drupal\Core\Database\Statement\FetchAs|null $mode: (Optional) one of the cases of the FetchAs enum. If not specified, defaults to what is specified by setFetchMode().

Return value

array|object|false A result, formatted according to $mode, or FALSE on failure.

Overrides StatementInterface::fetch

1 call to StatementBase::fetch()
StatementBase::fetchAssoc in core/lib/Drupal/Core/Database/Statement/StatementBase.php

File

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

Class

StatementBase
StatementInterface base implementation.

Namespace

Drupal\Core\Database\Statement

Code

public function fetch(?FetchAs $mode = NULL) {
  $row = $this->result
    ->fetch($mode ?? $this->fetchMode, $this->fetchOptions);
  if ($row === FALSE) {
    $this->markResultsetFetchingComplete();
    return FALSE;
  }
  $this->setResultsetCurrentRow($row);
  return $row;
}

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