function db_field_names in Drupal 8
Same name and namespace in other branches
- 6 includes/database.inc \db_field_names()
- 7 includes/database/database.inc \db_field_names()
Returns 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
array $fields: An array of key/index column specifiers.
Return value
array An array of field names.
Deprecated
in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call fieldNames() on it. For example, $injected_database->schema()->fieldNames($fields);
See also
https://www.drupal.org/node/2993033
\Drupal\Core\Database\Schema::fieldNames()
Related topics
1 call to db_field_names()
- DatabaseLegacyTest::testDbFieldNames in core/
tests/ Drupal/ KernelTests/ Core/ Database/ DatabaseLegacyTest.php - Tests deprecation of the db_field_names() function.
File
- core/
includes/ database.inc, line 652 - Core systems for the database layer.
Code
function db_field_names($fields) {
@trigger_error('db_field_names() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call fieldNames() on it. For example, $injected_database->schema()->fieldNames($fields). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
return Database::getConnection()
->schema()
->fieldNames($fields);
}