You are here

public function Statement::fetchAllKeyed in Drupal driver for SQL Server and SQL Azure 8.2

Same name in this branch
  1. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php \Drupal\Driver\Database\sqlsrv\Statement::fetchAllKeyed()
  2. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/PDO/Statement.php \Drupal\Driver\Database\sqlsrv\PDO\Statement::fetchAllKeyed()
Same name and namespace in other branches
  1. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php \Drupal\Driver\Database\sqlsrv\Statement::fetchAllKeyed()

Optimized for common use cases.

Parameters

int $key_index:

int $value_index:

Return value

array

Overrides Statement::fetchAllKeyed

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php, line 139
Definition of Drupal\Driver\Database\sqlsrv\Statement

Class

Statement

Namespace

Drupal\Driver\Database\sqlsrv

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;
}