function _backup_migrate_dump_table_data_sql_to_file in Backup and Migrate 8.2
Get the sql to insert the data for a given table
1 call to _backup_migrate_dump_table_data_sql_to_file()
- backup_migrate_backup_db_to_file_mysql in includes/
db.mysql.inc - Get the sql dump file.
File
- includes/
db.mysql.inc, line 90
Code
function _backup_migrate_dump_table_data_sql_to_file($file, $table) {
$lines = 0;
$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" : "'" . mysql_escape_string($value) . "'";
}
if ($items) {
$file
->write("INSERT INTO `" . $table->name . "` VALUES (" . implode(",", $items) . ");\n");
$lines++;
}
}
return $lines;
}