You are here

function _demo_table_is_view in Demonstration site (Sandbox / Snapshot) 6

Same name and namespace in other branches
  1. 8 demo.module \_demo_table_is_view()
  2. 7 database_mysql_dump.inc \_demo_table_is_view()

Determine whether the given table is a VIEW.

1 call to _demo_table_is_view()
demo_dump_db in ./database_mysql_dump.inc
Dump active database.

File

./database_mysql_dump.inc, line 340

Code

function _demo_table_is_view($table) {
  static $tables = array();
  if (!isset($tables[$table])) {
    $status = db_fetch_array(db_query("SHOW TABLE STATUS LIKE '%s'", $table));

    // Column keys in $status start with a lower-case letter in PDO and with a
    // upper-case letter otherwise. We convert all to lower-case.
    foreach ($status as $key => $value) {
      $key_lower = drupal_strtolower($key);
      if ($key != $key_lower) {
        $status[$key_lower] = $value;
      }
    }
    $tables[$table] = drupal_strtoupper(drupal_substr($status['comment'], 0, 4)) == 'VIEW';
  }
  return $tables[$table];
}