public function Statement::fetchAllKeyed in Drupal driver for SQL Server and SQL Azure 8
Same name and namespace in other branches
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php \Drupal\Driver\Database\sqlsrv\Statement::fetchAllKeyed()
Experimental, do not iterate if not needed.
Parameters
mixed $key_index:
mixed $value_index:
Return value
array|Statement
Overrides Statement::fetchAllKeyed
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Statement.php, line 143 - Definition of Drupal\Driver\Database\sqlsrv\Statement
Class
Namespace
Drupal\Driver\Database\sqlsrvCode
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
// If we are asked for the default behaviour, rely
// on the PDO as being faster. The result set needs to exactly bee 2 columns.
if ($key_index == 0 && $value_index == 1 && $this
->columnCount() == 2) {
$this
->setFetchMode(PDO::FETCH_KEY_PAIR);
return $this
->fetchAll();
}
// We need to do this manually.
$return = array();
$this
->setFetchMode(PDO::FETCH_NUM);
foreach ($this as $record) {
$return[$record[$key_index]] = $record[$value_index];
}
return $return;
}