function db_field_set_no_default in Drupal 8
Same name and namespace in other branches
- 6 includes/database.mysql-common.inc \db_field_set_no_default()
- 6 includes/database.pgsql.inc \db_field_set_no_default()
- 7 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 - Core systems for the database layer.
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);
}