You are here

function date_column_exists in Date 5.2

See if a table column already exists.

2 calls to date_column_exists()
date_copy_convert_events in date_copy/date_copy.module
date_db_integrity in date/date.install

File

date/date.install, line 560

Code

function date_column_exists($table, $column) {
  global $db_type;
  switch ($db_type) {
    case 'mysql':
    case 'mysqli':
      return (bool) db_fetch_object(db_query("SHOW COLUMNS FROM {" . db_escape_table($table) . "} LIKE '" . db_escape_table($column) . "'"));
    case 'postgres':
      return (bool) db_result(db_query("SELECT COUNT(pg_attribute.attname) FROM pg_class, pg_attribute WHERE pg_attribute.attrelid = pg_class.oid AND pg_class.relname = '{" . db_escape_table($table) . "}' AND attname = '" . db_escape_table($column) . "'"));
  }
}