function StatementWrapper::fetchAll

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Database/StatementWrapper.php \Drupal\Core\Database\StatementWrapper::fetchAll()

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

array An array of results.

Overrides StatementInterface::fetchAll

2 calls to StatementWrapper::fetchAll()
StatementWrapper::fetchCol in core/lib/Drupal/Core/Database/StatementWrapper.php
Returns an entire single column of a result set as an indexed array.
StatementWrapper::getIterator in core/lib/Drupal/Core/Database/StatementWrapper.php

File

core/lib/Drupal/Core/Database/StatementWrapper.php, line 262

Class

StatementWrapper
Implementation of StatementInterface encapsulating PDOStatement.

Namespace

Drupal\Core\Database

Code

public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
  // Call \PDOStatement::fetchAll to fetch all rows.
  // \PDOStatement is picky about the number of arguments in some cases so we
  // need to be pass the exact number of arguments we where given.
  switch (func_num_args()) {
    case 0:
      return $this->clientStatement
        ->fetchAll();
    case 1:
      return $this->clientStatement
        ->fetchAll($mode);
    case 2:
      return $this->clientStatement
        ->fetchAll($mode, $column_index);
    case 3:
    default:
      return $this->clientStatement
        ->fetchAll($mode, $column_index, $constructor_arguments);
  }
}

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