function StatementWrapper::fetchAllKeyed

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

File

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

Class

StatementWrapper
Implementation of StatementInterface encapsulating PDOStatement.

Namespace

Drupal\Core\Database

Code

public function fetchAllKeyed($key_index = 0, $value_index = 1) {
  $return = [];
  $this->setFetchMode(\PDO::FETCH_NUM);
  foreach ($this as $record) {
    $return[$record[$key_index]] = $record[$value_index];
  }
  return $return;
}

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