W3cubDocs

/Drupal 8

public function StatementPrefetch::fetchAll

public StatementPrefetch::fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL)

Returns an array containing all of the result set rows.

Parameters

$mode: One of the PDO::FETCH_* constants.

$column_index: If $mode is PDO::FETCH_COLUMN, the index of the column to fetch.

$constructor_arguments: If $mode is PDO::FETCH_CLASS, the arguments to pass to the constructor.

Return value

An array of results.

Overrides StatementInterface::fetchAll

File

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

Class

StatementPrefetch
An implementation of StatementInterface that prefetches all data.

Namespace

Drupal\Core\Database

Code

public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
  $this->fetchStyle = isset($mode) ? $mode : $this->defaultFetchStyle;
  $this->fetchOptions = $this->defaultFetchOptions;
  if (isset($column_index)) {
    $this->fetchOptions['column'] = $column_index;
  }
  if (isset($constructor_arguments)) {
    $this->fetchOptions['constructor_args'] = $constructor_arguments;
  }

  $result = array();
  // Traverse the array as PHP would have done.
  while (isset($this->currentRow)) {
    // Grab the row in the format specified above.
    $result[] = $this->current();
    $this->next();
  }

  // Reset the fetch parameters to the value stored using setFetchMode().
  $this->fetchStyle = $this->defaultFetchStyle;
  $this->fetchOptions = $this->defaultFetchOptions;
  return $result;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!StatementPrefetch.php/function/StatementPrefetch::fetchAll/8.1.x