You are here

function schema_sql in Schema 6

Same name and namespace in other branches
  1. 5 schema.module \schema_sql()
  2. 7 schema.pages.inc \schema_sql()

"SQL" menu callback.

1 string reference to 'schema_sql'
schema_menu in ./schema.module
Implementation of hook_menu(). Define menu items and page callbacks. admin/build/schema calls local task(default): schema_report() admin/build/schema/report calls local task: schema_report() admin/build/schema/describe calls local task:…

File

./schema.module, line 836
The Schema module provides functionality built on the Schema API.

Code

function schema_sql($engine = NULL) {
  $schema = drupal_get_schema(NULL, TRUE);
  $sql = '';
  foreach ($schema as $name => $table) {
    if (substr($name, 0, 1) == '#') {
      continue;
    }
    if ($engine) {
      $stmts = call_user_func('schema_' . $engine . '_create_table_sql', $table);
    }
    else {
      $stmts = db_create_table_sql($name, $table);
    }
    $sql .= implode(";\n", $stmts) . ";\n\n";
  }
  $output = <<<EOT
<p>This page shows the CREATE TABLE statements that the Schema module
generates for the selected database engine for each table defined by a
module.  It is for debugging purposes.</p>
<textarea style="width:100%" rows="30">{<span class="php-variable">$sql</span>}</textarea>
EOT;
  return $output;
}