function db_drop_field

Same name in other branches
  1. 7.x includes/database/database.inc \db_drop_field()

Drops a field.

Parameters

$table: The table to be altered.

$field: The field to be dropped.

Return value

bool TRUE if the field was successfully dropped, FALSE if there was no field by that name to begin with.

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 dropField() on it. For example, $injected_database->schema()->dropField($table, $field);

See also

https://www.drupal.org/node/2993033

\Drupal\Core\Database\Schema::dropField()

Related topics

1 call to db_drop_field()
DatabaseLegacyTest::testDbDropField in core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php
Tests deprecation of the db_drop_field() function.

File

core/includes/database.inc, line 849

Code

function db_drop_field($table, $field) {
    @trigger_error('db_drop_field() 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 dropField() on it. For example, $injected_database->schema()->dropField($table, $field). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
    return Database::getConnection()->schema()
        ->dropField($table, $field);
}

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