function _backup_migrate_dump_table_data_sql_to_handle in Backup and Migrate 5
Same name and namespace in other branches
- 5.2 includes/db.inc \_backup_migrate_dump_table_data_sql_to_handle()
- 6 backup_migrate.module \_backup_migrate_dump_table_data_sql_to_handle()
Get the sql to insert the data for a given table
1 call to _backup_migrate_dump_table_data_sql_to_handle()
- _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 640 - 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_dump_table_data_sql_to_handle($dst, $table) {
$data = db_query("SELECT * FROM `" . $table['Name'] . "`");
while ($row = db_fetch_array($data)) {
$items = array();
foreach ($row as $key => $value) {
$items[] = is_null($value) ? "null" : "'" . db_escape_string($value) . "'";
}
if ($items) {
fwrite($dst, "INSERT INTO `" . $table['Name'] . "` VALUES (" . implode(",", $items) . ");\n");
}
}
}