db_column_exists

Definition

db_column_exists($table, $column)
drupal/includes/database/database.inc, line 2539

Description

Checks if a column exists in the given table.

Parameters

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

$name The name of the column.

Return value

TRUE if the given column exists, otherwise FALSE.

Related topics

Namesort iconDescription
Database abstraction layerAllow the use of different database servers using the same code base.
Schema APIA Drupal schema definition is an array structure representing one or more tables and their related keys and indexes. A schema is defined by hook_schema(), which usually lives in a modulename.install file.

Code

function db_column_exists($table, $column) {
  return Database::getConnection()->schema()->columnExists($table, $column);
}