function Statement::fetchAllKeyed

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Statement.php \Drupal\Core\Database\Statement::fetchAllKeyed()

Overrides StatementInterface::fetchAllKeyed

File

core/lib/Drupal/Core/Database/Statement.php, line 108

Class

Statement
Default implementation of StatementInterface.

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.