function db_column_exists
6.x database.pgsql.inc | db_column_exists($table, $column) |
6.x database.mysqli.inc | db_column_exists($table, $column) |
6.x database.mysql.inc | db_column_exists($table, $column) |
Check if a column exists in the given table.
Parameters
$table: The name of the table.
$column: The name of the column.
Return value
TRUE if the column exists, and FALSE if the column does not exist.
Related topics
1 call to db_column_exists()
- system_update_6051 in drupal-6.x/
modules/ system/ system.install - Create a signature_format column.
File
- drupal-6.x/
includes/ database.mysqli.inc, line 370 - Database interface code for MySQL database servers using the mysqli client libraries. mysqli is included in PHP 5 by default and allows developers to use the advanced features of MySQL 4.1.x, 5.0.x and beyond.
Code
function db_column_exists($table, $column) {
return (bool) db_fetch_object(db_query("SHOW COLUMNS FROM {" . db_escape_table($table) . "} LIKE '" . db_escape_table($column) . "'"));
}