function Statement::fetchAllKeyed

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

Overrides StatementInterface::fetchAllKeyed

File

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

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.