You are here

function _demo_table_is_view in Demonstration site (Sandbox / Snapshot) 7

Same name and namespace in other branches
  1. 8 demo.module \_demo_table_is_view()
  2. 6 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 327

Code

function _demo_table_is_view($table) {
  static $tables = array();
  if (!isset($tables[$table])) {
    $status = db_query('SHOW TABLE STATUS LIKE :table', array(
      ':table' => $table,
    ))
      ->fetchAssoc();

    // Capitalization of keys depends on PDO database connection options.
    $comment = isset($status['Comment']) ? $status['Comment'] : $status['comment'];
    $tables[$table] = strtoupper(substr($comment, 0, 4)) == 'VIEW';
  }
  return $tables[$table];
}