You are here

function _backup_migrate_get_table_structure_sql in Backup and Migrate 5.2

Same name and namespace in other branches
  1. 5 backup_migrate.module \_backup_migrate_get_table_structure_sql()
  2. 6 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 includes/db.inc
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

includes/db.inc, line 83
General database dump/restore code for Backup and Migrate.

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;
}