function FetchModeTrait::assocToColumn
Same name in other branches
- 10 core/lib/Drupal/Core/Database/FetchModeTrait.php \Drupal\Core\Database\FetchModeTrait::assocToColumn()
Converts a row of data in FETCH_ASSOC format to FETCH_COLUMN.
Parameters
array $rowAssoc: A row of data in FETCH_ASSOC format.
string[] $columnNames: The list of the row columns.
int $columnIndex: The index of the column to fetch the value of.
Return value
string The value of the column.
Throws
\ValueError If the column index is not defined.
1 call to FetchModeTrait::assocToColumn()
- StatementPrefetchIterator::fetchField in core/
lib/ Drupal/ Core/ Database/ StatementPrefetchIterator.php - Returns a single field from the next record of a result set.
File
-
core/
lib/ Drupal/ Core/ Database/ FetchModeTrait.php, line 108
Class
- FetchModeTrait
- Provide helper methods for statement fetching.
Namespace
Drupal\Core\DatabaseCode
protected function assocToColumn(array $rowAssoc, array $columnNames, int $columnIndex) : mixed {
if (!isset($columnNames[$columnIndex])) {
throw new \ValueError('Invalid column index');
}
return $rowAssoc[$columnNames[$columnIndex]];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.