function FetchModeTrait::assocToColumn

Same name and namespace in other branches
  1. 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|false The value of the column, or FALSE if the column is not defined.

File

core/lib/Drupal/Core/Database/FetchModeTrait.php, line 105

Class

FetchModeTrait
Provide helper methods for statement fetching.

Namespace

Drupal\Core\Database

Code

protected function assocToColumn(array $rowAssoc, array $columnNames, int $columnIndex) : mixed {
    return $rowAssoc[$columnNames[$columnIndex]] ?? FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.