function StatementWrapperIterator::fetchAllKeyed
Same name in other branches
- 10 core/lib/Drupal/Core/Database/StatementWrapperIterator.php \Drupal\Core\Database\StatementWrapperIterator::fetchAllKeyed()
Overrides StatementInterface::fetchAllKeyed
File
-
core/
lib/ Drupal/ Core/ Database/ StatementWrapperIterator.php, line 195
Class
- StatementWrapperIterator
- StatementInterface iterator implementation.
Namespace
Drupal\Core\DatabaseCode
public function fetchAllKeyed($key_index = 0, $value_index = 1) {
$this->setFetchMode(\PDO::FETCH_NUM);
// Return early if the statement was already fully traversed.
if (!$this->isResultsetIterable) {
return [];
}
// Once the while loop is completed, the resultset is marked so not to
// allow more fetching.
$return = [];
while ($record = $this->fetch()) {
$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.