You are here

function _backup_migrate_get_table_structure_sql in Backup and Migrate 6

Same name and namespace in other branches
  1. 5.2 includes/db.inc \_backup_migrate_get_table_structure_sql()
  2. 5 backup_migrate.module \_backup_migrate_get_table_structure_sql()

Get the sql for the structure of the given table.

1 call to _backup_migrate_get_table_structure_sql()
_backup_migrate_get_dump_sql in ./backup_migrate.module
Get the sql dump file. Returns a list of sql commands, one command per line. That makes it easier to import without loading the whole file into memory. The files are a little harder to read, but human-readability is not a priority

File

./backup_migrate.module, line 603
Create (manually or scheduled) and restore backups of your Drupal MySQL database with an option to exclude table data (f.e. cache_*)

Code

function _backup_migrate_get_table_structure_sql($table) {
  $out = "";
  $result = db_query("SHOW CREATE TABLE `" . $table['Name'] . "`");
  if ($create = db_fetch_array($result)) {
    $out .= "DROP TABLE IF EXISTS `" . $table['Name'] . "`;\n";
    $out .= strtr($create['Create Table'], "\n", " ");
    if ($table['Auto_increment']) {
      $out .= " AUTO_INCREMENT=" . $table['Auto_increment'];
    }
    $out .= ";\n";
  }
  return $out;
}