function db_field_exists

Checks if a column exists in the given table.

Parameters

$table: The name of the table in drupal (no prefixing).

$field: The name of the field.

Return value

TRUE if the given column exists, otherwise FALSE.

Related topics

6 calls to db_field_exists()
DatabaseRegressionTestCase::testDBFieldExists in drupal/modules/simpletest/tests/database_test.test
Test the db_field_exists() function.
field_sql_storage_update_7001 in drupal/modules/field/modules/field_sql_storage/field_sql_storage.install
Remove the field_config_entity_type table and store 'entity_type' strings.
SchemaTestCase::testUnsignedColumns in drupal/modules/simpletest/tests/schema.test
Tests creating unsigned columns and data integrity thereof.
user_update_7002 in drupal/modules/user/user.install
Convert user time zones from time zone offsets to time zone names.
user_update_7006 in drupal/modules/user/user.install
Add module data to {role_permission}.

... See full list

File

drupal/includes/database/database.inc, line 2834
Core systems for the database layer.

Code

function db_field_exists($table, $field) {
  return Database::getConnection()
    ->schema()
    ->fieldExists($table, $field);
}