You are here

function _backup_migrate_get_table_structure_sql_mysql in Backup and Migrate 8.2

Get the sql for the structure of the given table.

1 call to _backup_migrate_get_table_structure_sql_mysql()
backup_migrate_backup_db_to_file_mysql in includes/db.mysql.inc
Get the sql dump file.

File

includes/db.mysql.inc, line 72

Code

function _backup_migrate_get_table_structure_sql_mysql($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'], array(
      "\n" => " ",
      '"' => '`',
    ));
    if ($table->auto_increment) {
      $out .= " AUTO_INCREMENT=" . $table->auto_increment;
    }
    $out .= ";\n";
  }
  return $out;
}