public function Statement::fetchAllKeyed in Drupal driver for SQL Server and SQL Azure 8.2
Same name in this branch
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php \Drupal\Driver\Database\sqlsrv\Statement::fetchAllKeyed()
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/PDO/Statement.php \Drupal\Driver\Database\sqlsrv\PDO\Statement::fetchAllKeyed()
Optimized for common use cases.
Parameters
int $key_index:
int $value_index:
Return value
array
1 method overrides Statement::fetchAllKeyed()
- Statement::fetchAllKeyed in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Statement.php - Optimized for common use cases.
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ PDO/ Statement.php, line 365
Class
- Statement
- Turbocharged Statement class to work with MSSQL server.
Namespace
Drupal\Driver\Database\sqlsrv\PDOCode
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;
}