function db_field_set_no_default
Same name in other branches
- 7.x includes/database/database.inc \db_field_set_no_default()
Sets a field to have no default value.
Parameters
$table: The table to be altered.
$field: The field to be altered.
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 changeField() on it, passing a full field specification. For example, $injected_database->schema() ->changeField($table, $field, $field_new, $spec, $keys_new);
See also
https://www.drupal.org/node/2993033
\Drupal\Core\Database\Schema::changeField()
Related topics
1 call to db_field_set_no_default()
- DatabaseLegacyTest::testDbFieldSetNoDefault in core/
tests/ Drupal/ KernelTests/ Core/ Database/ DatabaseLegacyTest.php - Tests deprecation of the db_field_set_no_default() function.
File
-
core/
includes/ database.inc, line 897
Code
function db_field_set_no_default($table, $field) {
@trigger_error('db_field_set_no_default() 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 changeField() on it, passing a full field specification. For example, $injected_database->schema()->changeField($table, $field, $field_new, $spec, $keys_new). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
return Database::getConnection()->schema()
->fieldSetNoDefault($table, $field);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.