function demo_dump_db in Demonstration site (Sandbox / Snapshot) 5
Same name and namespace in other branches
- 8 demo.module \demo_dump_db()
- 6 database_mysql_dump.inc \demo_dump_db()
- 7 database_mysql_dump.inc \demo_dump_db()
Dump active database.
1 call to demo_dump_db()
File
- ./
database_mysql_dump.inc, line 11
Code
function demo_dump_db($filename, $exclude = array()) {
// Make sure we have permission to save our backup file.
$directory = dirname($filename);
if (!file_check_directory($directory, FILE_CREATE_DIRECTORY)) {
return FALSE;
}
if ($fp = fopen($filename, 'wb')) {
$header = "-- Demo.module database dump (version " . DEMO_DUMP_VERSION . ")\n";
$header .= "-- http://drupal.org/project/demo\n";
$header .= "--\n";
$header .= "-- Database: " . _demo_get_database() . "\n";
$header .= "-- Date: " . format_date(time(), 'large') . "\n";
// Temporarily disable foreign key checks for the time of import.
$header .= "SET FOREIGN_KEY_CHECKS = 0;\n";
fwrite($fp, $header);
foreach (demo_enum_tables() as $table) {
// Always export structure to allow creating a new site
// from a database dump
fwrite($fp, _demo_dump_table_structure($table));
if (!in_array($table, $exclude)) {
fwrite($fp, _demo_dump_table_data($table));
}
}
// Re-enable foreign key checks.
fwrite($fp, "\nSET FOREIGN_KEY_CHECKS = 1;\n");
fclose($fp);
return TRUE;
}
return FALSE;
}