function Schema::fieldNames

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::fieldNames()
  2. 8.9.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::fieldNames()
  3. 10 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::fieldNames()

Return an array of field names from an array of key/index column specifiers.

This is usually an identity function but if a key/index uses a column prefix specification, this function extracts just the name.

Parameters

$fields: An array of key/index column specifiers.

Return value

array An array of field names.

File

core/lib/Drupal/Core/Database/Schema.php, line 661

Class

Schema
Provides a base implementation for Database Schema.

Namespace

Drupal\Core\Database

Code

public function fieldNames($fields) {
    $return = [];
    foreach ($fields as $field) {
        if (is_array($field)) {
            $return[] = $field[0];
        }
        else {
            $return[] = $field;
        }
    }
    return $return;
}

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